Download Chapter 4

Document related concepts

Zigbee wikipedia , lookup

CAN bus wikipedia , lookup

Peering wikipedia , lookup

Net bias wikipedia , lookup

Distributed firewall wikipedia , lookup

IEEE 1355 wikipedia , lookup

Deep packet inspection wikipedia , lookup

Asynchronous Transfer Mode wikipedia , lookup

Multiprotocol Label Switching wikipedia , lookup

IEEE 802.1aq wikipedia , lookup

Wake-on-LAN wikipedia , lookup

Piggybacking (Internet access) wikipedia , lookup

Computer network wikipedia , lookup

Internet protocol suite wikipedia , lookup

Network tap wikipedia , lookup

Zero-configuration networking wikipedia , lookup

Cracking of wireless networks wikipedia , lookup

List of wireless community networks by region wikipedia , lookup

Airborne Networking wikipedia , lookup

UniPro protocol stack wikipedia , lookup

Routing wikipedia , lookup

Routing in delay-tolerant networking wikipedia , lookup

Recursive InterNetwork Architecture (RINA) wikipedia , lookup

Transcript
Chapter 4
Network Layer
A note on the use of these ppt slides:
We’re making these slides freely available to all (faculty, students, readers).
They’re in PowerPoint form so you can add, modify, and delete slides
(including this one) and slide content to suit your needs. They obviously
represent a lot of work on our part. In return for use, we only ask the
following:
 If you use these slides (e.g., in a class) in substantially unaltered form,
that you mention their source (after all, we’d like people to use our book!)
 If you post any slides in substantially unaltered form on a www site, that
you note that they are adapted from (or perhaps identical to) our slides, and
note our copyright of this material.
Computer Networking:
A Top Down Approach
4th edition.
Jim Kurose, Keith Ross
Addison-Wesley, July
2007.
Thanks and enjoy! JFK/KWR
All material copyright 1996-2007
J.F Kurose and K.W. Ross, All Rights Reserved
Network Layer
4-1
Chapter 4: Network Layer
Chapter goals:
 understand principles behind network layer
services:
IP addressing (寻址)
 forwarding versus routing (转发 vs 路由)
 routing (path selection)
 advanced topics: IPv6, mobility

 instantiation, implementation in the Internet
Network Layer
4-2
Chapter 4: Network Layer
 4. 1 Introduction
 4.2 Virtual circuit and
datagram networks
 4.3 What’s 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
multicast routing
Network Layer
4-3
Vocabulary and Term
 Virtual Circuit (VC) /Datagram
 虚电路/数据报
 Router/Switch/Hub/Repeater
 路由器/交换机/集线器/中继器
 Input/Output Port
 输入/输出 端口
 Switch Fabric 、Crossbar
 交换结构、交叉开关
 Forwarding/Routing
 转发/路由
 FIB (Forwarding Information Base)/Route Table
 转发表/路由表
Network Layer
4-4
Chapter 4: Network Layer
 4. 1 Introduction
 4.2 Virtual circuit and
datagram networks
 4.3 What’s 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
multicast routing
Network Layer
4-5
Protocol:comm rules
Host 2
Host 1
Segment
App. Layer
4
L4
34
L3
Assemble
App. Layer
L4 Protocol
L4
4
L3
34
L2
2 34
Data
Data
App. Protocol
Header
2 34
1 2 34
L2
L1
L3 Protocol
L2 Protocol
Interface
L1 Protocol
Media
L1
1 2 34
Network Layer
4-6
Network layer
 transport segment from




sending to receiving host
on sending side
encapsulates segments
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
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
network
data link
data link
physical
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
Network Layer
application
transport
network
data link
physical
4-7
Journey of a Packet
Host
Host
5
Router
4
4
3
L3
3
3
Switch
2 3
Hub
2
1
5
L2
L1
2
L2
1 2 3
L1
2 3
1 2 3
1
L1
Network Layer
4-8
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

analogy:
 routing: process of
planning trip from
source to destination
 forwarding: process
of getting through
single interchange
routing algorithms
Network Layer
4-9
Router Functions
Dest
Packet
Next-hop Cal.
Dest
Port/NH
-------
-------
----
----
Select Best Route

Forwarding
(Interface ij)

Control(Congest,
Security)

Next-Hop
Network Layer 4-10
Router Startup
 Power-On Self Test (POST)
 Boot ROM
 Loading OS
 IOS in Flash
 Loading Configure Information
 Config file in NVRAM
 Run applications
Network Layer
4-11
Interplay between routing and forwarding
routing algorithm
local forwarding table
header value output link
0100
0101
0111
1001
3
2
2
1
value in arriving
packet’s header
0111
1
3 2
Network Layer 4-12
Connection setup
 3rd 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
inervening routers in case of Virtual Circuits)
 transport: between two processes

Network Layer 4-13
Network service model
Q: What network service model for “channel”
transporting datagrams from sender to receiver?
Example services for
individual datagrams:
 guaranteed delivery
 guaranteed delivery
with less than 40 msec
delay
Example services for a flow
of datagrams:
 in-order datagram
delivery
 guaranteed minimum
bandwidth to flow
 restrictions on changes in
inter-packet spacing
Network Layer 4-14
Network layer service models:
Network
Architecture
Internet
Service
Model
Guarantees ?
Congestion
Bandwidth Loss Order Timing feedback
best effort none
ATM
CBR
ATM
VBR
ATM
ABR
ATM
UBR
constant
rate
guaranteed
rate
guaranteed
minimum
none
no
no
no
yes
yes
yes
yes
yes
yes
no
yes
no
no (inferred
via loss)
no
congestion
no
congestion
yes
no
yes
no
no
Network Layer 4-15
Chapter 4: Network Layer
 4. 1 Introduction
 4.2 Virtual circuit and
datagram networks
 4.3 What’s 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
multicast routing
Network Layer 4-16
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

Network Layer 4-17
Virtual circuits
“source-to-destination 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-destination path maintains “state”
for each passing connection
 link, router resources (bandwidth, buffers) may be
allocated to VC (dedicated resources = predictable service)
Network Layer 4-18
Recall
Circuit Switching
 dedicated resources: no sharing
 guaranteed performance
Network Layer 4-19
VC implementation
a VC consists of:
1.
2.
3.
path from source to destination
VC numbers, one number for each link along
path
entries in forwarding tables in routers along
path
 packet belonging to VC carries VC number
(rather than destination address)
 VC number can be changed on each link.

New VC number comes from forwarding table
Network Layer 4-20
Forwarding table
VC number
22
12
1
Forwarding table in
northwest router:
Incoming interface
1
2
3
1
…
2
32
3
interface
number
Incoming VC #
12
63
7
97
…
Outgoing interface
3
1
2
3
…
Outgoing VC #
22
18
17
87
…
Routers maintain connection state information!
Network Layer 4-21
Virtual circuits: signaling protocols
 used to setup, maintain teardown VC
 used in ATM, frame-relay, X.25
 not used in today’s Internet
application
transport 5. Data flow begins
network 4. Call connected
data link 1. Initiate call
physical
6. Receive data application
3. Accept call
2. incoming call
transport
network
data link
physical
Network Layer 4-22
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
application
transport
network
data link 1. Send data
physical
application
transport
network
2. Receive data
data link
physical
Network Layer 4-23
Summary
Circuit Exchange
Exchange
Technology
Message Switching
Store & Forwarding
Virtual Circuit
Packet Switching
Datagram
Network Layer 4-24
Forwarding table
Destination Address Range
4 billion
possible entries ?
Link Interface
11001000 00010111 00010000 00000000
through
11001000 00010111 00010111 11111111
0
11001000 00010111 00011000 00000000
through
11001000 00010111 00011000 11111111
1
11001000 00010111 00011001 00000000
through
11001000 00010111 00011111 11111111
2
otherwise
3
Network Layer 4-25
Longest prefix matching
Prefix Match
11001000 00010111 00010
11001000 00010111 00011000
11001000 00010111 00011
otherwise
Link Interface
0
1
2
3
Examples
DA: 11001000 00010111 00010110 10100001
Which interface?
DA: 11001000 00010111 00011000 10101010
Which interface?
Network Layer 4-26
Datagram or VC network: why?
Internet (datagram)
 data exchange among
ATM (VC)
 evolved from telephony
computers
 human conversation:
 “elastic” service, no strict
 strict timing, reliability
timing req.
requirements
 “smart” end systems
 need for guaranteed
(computers)
service
 can adapt, perform
 “dumb” end systems
control, error recovery
 telephones
 simple inside network,
 complexity inside
complexity at “edge”
network
 many link types
 different characteristics
 uniform service difficult
Network Layer 4-27
Chapter 4: Network Layer
 4. 1 Introduction
 4.2 Virtual circuit and
datagram networks
 4.3 What’s 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
multicast routing
Network Layer 4-28
CISCO Routers
Cisco12000
Cisco7500
Cisco7200
As5800
As5200/5300
Cisco4000
Cisco3600
Cisco2600
Cisco2500
Cisco1600
Network Layer 4-29
Routers: Low/Middle Performance
Network Layer 4-30
Router: High-Performance
CISCO 12000
Lucent NX64000
Juniper T640
Network Layer 4-31
Router Inside
 Cisco 2600
Front end
Back end
Network Layer 4-32
COM Port
Network Layer 4-33
Router Organization
Network Layer 4-34
Network Layer 4-35
Router Architecture Overview
Two key router functions:
 run routing algorithms/protocol (RIP, OSPF, BGP)
 forwarding datagrams from incoming to outgoing link
Network Layer 4-36
Input Port Functions
Physical layer:
bit-level reception
Data link layer:
e.g., Ethernet
see chapter 5
Decentralized switching:
 given datagram destination, lookup output
port using forwarding table in input port
memory
 goal: complete input port processing at
‘line speed’
 queuing: if datagrams arrive faster than
forwarding rate into switch fabric
Network Layer 4-37
Three types of switching fabrics
Network Layer 4-38
Switching Via Memory
First generation routers:
 traditional computers with switching under direct
control of CPU
 packet copied to system’s memory
 speed limited by memory bandwidth (2 bus
crossings per datagram)
Input
Port
Memory
Output
Port
System Bus
Network Layer 4-39
Switching Via a Bus
 datagram from input port memory
to output port memory via a shared
bus
 bus contention: switching speed
limited by bus bandwidth
 32 Gbps bus, Cisco 5600: sufficient
speed for access and enterprise
routers
Network Layer 4-40
Switching Via An Interconnection
Network
 overcome bus bandwidth limitations
 Banyan networks, other interconnection nets
initially developed to connect processors in
multiprocessor
 advanced design: fragmenting datagram into fixed
length cells, switch cells through the fabric.
 Cisco 12000: switches 60 Gbps through the
interconnection network
Network Layer 4-41
Output Ports
 Buffering required when datagrams arrive from
fabric faster than the transmission rate
 Scheduling discipline chooses among queued
datagrams for transmission
Network Layer 4-42
Output port queueing
 buffering when arrival rate via switch exceeds
output line speed
 queueing (delay) and loss due to output port
buffer overflow!
Network Layer 4-43
How much buffering?
 RFC 3439 rule of thumb: average buffering
equal to “typical” RTT (say 250 msec) times
link capacity C

e.g., C = 10 Gbps link: 2.5 Gb buffer
 Recent recommendation: with N flows,
buffering equal to RTT. C
N
Network Layer 4-44
Input Port Queuing
 Fabric slower than input ports combined -> queueing
may occur at input queues
 Head-of-the-Line (HOL) blocking: queued datagram
at front of queue prevents others in queue from
moving forward
 queueing delay and loss due to input buffer overflow!
Network Layer 4-45
Fourth Generation Routers
Optical links
100s
of metres
Switch Core
Linecards
160Gb/s - 20Tb/s routers in development
Network Layer
4-46
Homework
 Reviews:2,3,7,10
Network Layer 4-47
Chapter 4: Network Layer
 4. 1 Introduction
 4.2 Virtual circuit and
datagram networks
 4.3 What’s 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
multicast routing
Network Layer 4-48
Network Layer 4-49
Network Layer 4-50
Network Layer 4-51
Packet
Ethernet
Header
IP
TCP
Header Header
HTTP
Header
e.g., HTTP Body
Network Layer 4-52
The Internet Network Layer
Host, router network layer functions:
Transport layer: TCP, UDP
Network
layer
IP protocol
•addressing conventions
•datagram format
•packet handling conventions
Routing protocols
•path selection
•RIP, OSPF, BGP
forwarding
table
ICMP protocol
•error reporting
•router “signaling”
Link layer
physical layer
Network Layer 4-53
IP datagram format
IP protocol version
number
header length
(bytes)
“type” of data
max number
remaining hops
(decremented at
each router)
upper layer protocol
to deliver payload to
how much overhead
with TCP?
 20 bytes of TCP
 20 bytes of IP
 = 40 bytes + app
layer overhead
32 bits
head. type of
length
ver
len service
fragment
16-bit identifier flgs
offset
upper
time to
header
layer
live
checksum
total datagram
length (bytes)
for
fragmentation/
reassembly
32 bit source IP address
32 bit destination IP address
Options (if any)
data
(variable length,
typically a TCP
or UDP segment)
E.g. timestamp,
record route
taken, specify
list of routers
to visit.
Network Layer 4-54
IP Format (Chinese Version)
Network Layer 4-55
TTL
head. type of
length
ver
len service
fragment
flgs
16-bit identifier
offset
time to upper
Header
layer
live
checksum
32 bit source IP address
32 bit destination IP address
Options (if any)
 Time to live
 max number remaining
hops
 decremented at each
router
 TTL=0: discard (only in
LAN when initial TTL=1)
 Too small to reach the
destination
 can be used to count hops
to destination
Network Layer 4-56
Internet Protocol Numbers :2008-02-27
 www.iana.org/assignments/protocol-numbers
 0-133:SAME
 134









RSVP-E2E-IGNORE
[RFC3175]
135
Mobility Header
[RFC3775]
136
UDPLite
[RFC3828]
137
MPLS-in-IP
[RFC4023]
138
manet MANET Protocols
[RFC-ietf-manet-iana-07.txt]
139
HIP
Host Identity Protocol [RFC-ietf-hip-base-10.txt]
140-252 Unassigned
[IANA]
253
Use for experimentation and testing
[RFC3692]
254
Use for experimentation and testing
[RFC3692]
255
Reserved
[IANA]
Network Layer 4-57
IP Fragmentation & Re-assemble
fragmentation:
in: one large datagram
out: 3 smaller datagrams
 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
reassembly
“re-assembled” only at
final destination
IP header bits used to
identify, order related
fragments
Network Layer 4-58
IP Fragmentation & Re-assemble
length ID fragflag offset
=4000 =x
=0
=0
Example: Ethernet
 4000 byte
datagram
 MTU = 1500 bytes
One large datagram becomes
several smaller datagrams
Flag = 1 there is more fragment
Flag = 0 this is the last
fragment
Offset: byte number of the 1st
byte of the fragment
(specified in units of 8-byte chunks)
length ID fragflag offset
=1500 =x
=1
=0
length ID fragflag offset
=1500 =x
=1
=185
length ID fragflag offset
=1040 =x
=0
=370
1480 bytes in
data field
offset =
1480/8
Network Layer 4-59
Chapter 4: Network Layer
 4. 1 Introduction
 4.2 Virtual circuit and
datagram networks
 4.3 What’s 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
multicast routing
Network Layer 4-60
Address Allocation
 IANA:Internet Assigned Numbers
Authority(互联网号码分配机构)

Domain name, IP address, protocol parameters,
root server management
 ICCAN:Internet Corporation for
Assigned Names and Numbers
allocates addresses
 manages DNS
 assigns domain names, resolves disputes

 ASO (Address Supporting Organization)
 Advisory on policy and structure
Network Layer 4-61
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
Network Layer 4-62
IP Addressing
 IP Address: Classful Addressing (有类寻址)

A,B,C,D,E
--5 Classes
 Network Mask (网络掩码)
 Classless Addressing (无类寻址)

Subnet (子网) & Supernet (超网)
 NAT (Network Address Translation)
Network Layer 4-63
IP Address Classes
8 bits
8 bits
8 bits
8 bits
Host
Host
Host
Host
Host
• Class A:
Network
• Class B:
Network Network
• Class C:
Network Network Network
• Class D:
Multicast
• Class E:
Research purpose
Host
Network Layer 4-64
Classful Addressing
Network Layer 4-65
IP in China
万个
16,000
14,000
13,527
中国IPv4地址
11,825
12,000
9,802
10,000
8,000
6,000
4,146
4,942
5,995
6,830
7,439
8,479
4,000
2,000
0
2003.12
2004.06 2004.12
2005.06 2005.12 2006.06
2006.12 2007.06
2007.12
Network Layer 4-66
IP in China (2005)
 Telcom:34.70%
 Netcom:21.40%
 CERNET:15.08%
 CNNIC:14.47%
 Unicom:3.07%
 Mobile:2.84%
 其他:8.43%
Network Layer 4-67
China IPv4 Allocation List (2007.1)
Network Layer 4-68
IP Address: 点分十进制表示法
主机的 IP 地址
是 32 位二进制代码
每隔 8 位插入一个空格
以提高可读性
将每 8位的二进制数
转换为十进制数表示
readable!
10000000000010110000001100011111
10000000 00001011 00000011 00011111
128
11
3
31
128.11.3.31
Network Layer 4-69
Number of Networks and Hosts
Class
Network
Number of Networks
Hosts for each
network
A
1.0.0.0 126.0.0.0
27 –2
(125)
224 -2
(16 777 216)
B
128.1.0.0 191.254.0.0
214 -2
(16384)
216 ( 64K )-2
(65 534)
C
192.0.1.0 223.255.254.0
221 –2
(>2million)
28-2
(254)
Network Layer 4-70
How to get Network ID:by Network Mask
Class
Bits for Network ID
Bits for host ID
Network Mask
A
8
24
255.0.0.0
B
16
16
255.255.0.0
C
24
8
255.255.255.0
IP Address “AND” mask=> Network
ID
Network Layer 4-71
Example:
Example1: First 8 bits are network ID
Address
8.1.4.5
0000 1000 0000 0001 0000 0100 0000 0101
Mask
255.0.0.0
1111 1111 0000 0000 0000 0000 0000 0000
Result
8.0.0.0
0000 1000 0000 0000 0000 0000 0000 0000
Example2: First 16 bits are network ID
Address
130.4.100.1
1000 0010 0000 0100 0110 0100 0000 0101
Mask
255.255.0.0
1111 1111 1111 1111 0000 0000 0000 0000
Result
130.4.0.0
1000 0010 0000 0100 0000 0000 0000 0000
Network Layer 4-72
TCP/IP Configuration
Network Layer 4-73
IP Address Classes Exercise
Address
Class
Network
Host
10.2.1.1
128.63.2.100
201.222.5.64
192.6.141.2
130.113.64.16
256.241.201.10
Network Layer 4-74
IP Address Classes Exercise
Answers
Address
Class
10.2.1.1
A
10.0.0.0
0.2.1.1
128.63.2.100
B
128.63.0.0
0.0.2.100
201.222.5.64
C
201.222.5.0
0.0.0.64
192.6.141.2
C
192.6.141.0
0.0.0.2
130.113.64.16
B
130.113.0.0
0.0.64.16
256.241.201.10
Network
Host
Nonexistent
Network Layer 4-75
Special IP Address
Network Layer 4-76
Host Addresses
172.16.2.2
10.1.1.1
10.6.24.2
E1
172.16.3.10
E0
172.16.2.1
10.250.8.11
172.16.12.12
172.16
Network
.
12 . 12
Host
10.180.30.118
Routing Table
Network
Interface
172.16.0.0
E0
10.0.0.0
E1
Network Layer 4-77
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
223.1.1.1
223.1.2.1
223.1.1.2
223.1.1.4
223.1.1.3
223.1.2.9
223.1.3.27
223.1.2.2
223.1.3.2
223.1.3.1
223.1.1.1 = 11011111 00000001 00000001 00000001
223
1
1
1
Network Layer 4-78
Why Subnetting?
 Computer School
 172.26.0.0 255.255.0.0: 172.26.0.0/16
 Labs


601:172.26.1.0-172.26.1.255
602:172.26.2.0-172.26.2.255



601: 172.26.1.0 255.255.255.0: 172.26.1.0/24
602: 172.26.2.0 255.255.255.0: 172.26.2.0/24
Network Layer 4-79
Subnets
223.1.1.1
 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
223.1.2.1
223.1.1.2
223.1.1.4
223.1.1.3
223.1.2.9
223.1.3.27
223.1.2.2
subnet
223.1.3.1
223.1.3.2
can physically reach each other
without intervening router
network consisting of 3 subnets
Network Layer 4-80
Subnets
223.1.1.2
How many?
223.1.1.1
223.1.1.4
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.2.1
223.1.3.27
223.1.2.2
223.1.3.1
223.1.3.2
Network Layer 4-81
Smaller Subnets
 172.26.1.0 : Lab 601 IP Address
 How to divide into 4 Sub-Groups?
(11000000 00011010 00000001 00000000)




172.26.1.0-172.26.1.63
172.26.1.64-172.26.1.127
172.26.1.128-172.26.1.191
172.26.1.192-172.26.1.255
(11000000 00011010 00000001 11111111)
Network Layer 4-82
What is the network number and mask for each
group?
 each subnet has 64 (256/4) hosts
 number of hosts is 64 (26)
 network mask has 32-6=26 bits, originally
network mask has 24 bits, i.e., 172.26.1.0/24
Now, we have the sub network mask
172.26.1.0/26
172.26.1.64/26
172.26.1.128/26
172.26.1.192/26
1111 1111 1111 1111 1111 1111 1100 0000
255.
255.
255.
?
Network Layer 4-83
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

subnet
part
host
part
11001000 00010111 00010000 00000000
200.23.16.0/23
Network Layer 4-84
How to get IP Address for a Host?
Question?
 hard-coded by system admin in a file


Wintel: 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”
Network Layer 4-85
DHCP: Dynamic Host Configuration Protocol
Goal: allow host to dynamically obtain its 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
an “on”
Support for mobile users who want to join network (more
shortly)
DHCP overview:
 host broadcasts “DHCP discover” msg
 DHCP server responds with “DHCP offer” msg
 host requests IP address: “DHCP request” msg
 DHCP server sends address: “DHCP ack” msg
Network Layer 4-86
DHCP client-server scenario
A
B
223.1.2.1
DHCP
server
223.1.1.1
223.1.1.2
223.1.1.4
223.1.2.9
223.1.2.2
223.1.1.3
223.1.3.1
223.1.3.27
223.1.3.2
E
arriving DHCP
client needs
address in this
network
Network Layer 4-87
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
time
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
Network Layer 4-88
How to get IP Address for a Host?
Q: How does network get subnet part of IP
address?
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
Organization 1
Organization 2
...
11001000 00010111 00010000 00000000
11001000 00010111 00010010 00000000
11001000 00010111 00010100 00000000
…..
….
200.23.16.0/23
200.23.18.0/23
200.23.20.0/23
….
Organization 7
11001000 00010111 00011110 00000000
200.23.30.0/23
Network Layer 4-89
Network Configuration
172.26.1.1
172.26.1.17
172.26.1.0/24
172.26.2.1
172.26.1.99
172.26.2.36
172.26.2.99
172.26.2.0/24
Network Layer 4-90
Number of Networks and Hosts
Class
Network
Number of Networks
Hosts for each
network
A
1.0.0.0 126.0.0.0
27 –2
(125)
224 -2
(16 777 216)
B
128.1.0.0 191.254.0.0
214 -2
(16384)
216 ( 64K )-2
(65 534)
C
192.0.1.0 223.255.254.0
221 –2
(>2million)
28-2
(254)
Network Layer 4-91
Special IP Address
Network Layer 4-92
用网络掩码划分子网号
 从IP地址的主机号中“借用”若干位作为子网编号,主
机号相应缩短,并通过网络掩码来识别。
子网-id
因特网部分
两级 IP 地址
网络号 net-id
因特网部分
三级 IP 地址
本地部分
主机号 host-id
本地部分
host-id
net-id
主机号
网络号
子网掩码
1111111111111111
11000000
00000000
(IP 地址) AND (子网掩码) = 网络号(Net-id)
Network Layer 4-93
用网络掩码划分子网号
 示例:
对于B类IP地址 168.16.0.0,把B类IP子网掩码从
255.255.0.0/16
改为: 255.255.192.0/18
由于将2位主机号作为子网ID,
可以组成 4 个子网号:00 ~ 11,再加上原来的 Net ID:
10101000.00010000.00000000.00000000,即168.16.0.0
各子网的实际 Net ID 最终就成了:
10101000.00010000.00000000.00000000 (168.16.0.0)
10101000.00010000.01000000.00000000 (168.16.64.0)
10101000.00010000.10000000.00000000 (168.16.128.0)
10101000.00010000.11000000.00000000 (168.16.192.0)
Network Layer 4-94
用网络掩码划分子网号
 示例:
对于B类IP地址 168.16.0.0,若子网数要求210个
需利用8位主机号作为子网ID,可提供254个子网
8位子网号
子网掩码: 255.255.255.0
10101000.00010000.XXXXXXXX.00000000
若子网数要求900个, 需将10位主机号作为子网ID,可提供1022
个子网。
子网掩码: 255.255.255.192
11111111 11111111 1 1 1 1 1 1 1 1 11000000
10位子网号
10101000.00010000.XXXXXXXX.XX000000
Network Layer 4-95
NAT: Network Address Translation
rest of
Internet
local network
(e.g., home network)
10.0.0/24
10.0.0.4
10.0.0.1
10.0.0.2
138.76.29.7
10.0.0.3
All datagrams leaving local
network have same single source
NAT IP address: 138.76.29.7,
different source port numbers
Datagrams with source or
destination in this network
have 10.0.0/24 address for
source, destination (as usual)
Network Layer 4-96
NAT: Network Address Translation
 Motivation: local network uses just one IP address as
far as outside world is concerned:
 range of addresses not needed from ISP: just one IP
address for all devices
 can change addresses of devices in local network
without notifying outside world
 can change ISP without changing addresses of
devices in local network
 devices inside local net not explicitly addressable,
visible by outside world (a security plus).
Network Layer 4-97
NAT: Network Address Translation
Implementation: NAT router must:



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
Network Layer 4-98
NAT: Network Address Translation
2: NAT router
changes datagram
source addr from
10.0.0.1, 3345 to
138.76.29.7, 5001,
updates table
2
NAT translation table
WAN side addr.
LAN side addr.
1: host 10.0.0.1
sends datagram to
128.119.40.186, 80
138.76.29.7, 5001 10.0.0.1, 3345
……
……
S: 10.0.0.1, 3345
D: 128.119.40.186, 80
S: 138.76.29.7, 5001
D: 128.119.40.186, 80
138.76.29.7
S: 128.119.40.186, 80
D: 138.76.29.7, 5001
3: Reply arrives
dest. address:
138.76.29.7, 5001
3
1
10.0.0.4
S: 128.119.40.186, 80
D: 10.0.0.1, 3345
10.0.0.1
10.0.0.2
4
10.0.0.3
4: NAT router
changes datagram
dest addr from
138.76.29.7, 5001 to 10.0.0.1, 3345
Network Layer 4-99
NAT: Network Address Translation
 16-bit port-number field:

Consider 60,000 simultaneous connections with
a single LAN-side address!
 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
IPv6
shortage should instead be solved by
Network Layer 4-100
NAT problem and its Solution
 client want to connect to
server with address 10.0.0.1


server address 10.0.0.1 local
Client
to LAN (client can’t use it as
destination address)
only one externally visible
NATted address: 138.76.29.7
 solution 1: statically
configure NAT to forward
incoming connection
requests at given port to
server

10.0.0.1
?
138.76.29.7
10.0.0.4
NAT
router
e.g., (123.76.29.7, port 2500)
always forwarded to 10.0.0.1
port 25000
Network Layer 4-101
NAT problem and its Solution
 solution 2: NAT Traversal
Universal Plug and Play (UPnP)
Internet Gateway Device
(IGD) Protocol. Allows
NATted host to:
 learn public IP address
(138.76.29.7)
 enumerate existing port
mappings
 add/remove port mappings
(with lease times)
10.0.0.1
IGD
10.0.0.4
138.76.29.7
NAT
router
i.e., automate static NAT port
map configuration
Network Layer 4-102
NAT problem and its Solution
 solution 3: relaying (used in Skype)
NATed server establishes connection to relay
 External client connects to relay
 relay bridges packets between to connections

2. connection to
relay initiated
by client
Client
3. relaying
established
1. connection to
relay initiated
by NATted host
138.76.29.7
10.0.0.1
NAT
router
Network Layer 4-103
Chapter 4: Network Layer
 4. 1 Introduction
 4.2 Virtual circuit and
datagram networks
 4.3 What’s 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
multicast routing
Network Layer 4-104
ICMP: Internet Control Message Protocol
 used by hosts & routers to communicate network-
level information
 error reporting: unreachable host, network, port,
protocol
 echo request/reply (ping)
 network-layer “above” IP:

ICMP messages carried in IP datagrams
 ICMP message: type, code + first 8 bytes of IP
datagram causing error
Network Layer 4-105
ICMP
 Internet Control Message Protocol(RFC792)
ICMP
Header
8-bit type
8-bit code
16-bit checksum
4Byte(variable content )
ICMP data( variable )
ICMP Message
Network Layer 4-106
ICMP Format
8 bits
ICMP Datagram
IP
Frame
帧头
8bits
Type
ICMP 头部 Code
16bits 16bits 16bits 32bits
Checksum ICMP
field1数据field2
IP 头部
field3
IP 数据区
帧数据区
Network Layer 4-107
ICMP Function
 Error Report (差错报告)
 Destination Unreachable:
 Timeout (TTL =0 )
:
 Parameter Problem
:
3
11
12
 Data Control (数据控制)

Data Quench(信源抑制) :

Redirect (重定向) :
5
4
(D-R1-R2-S,S-R2S-R1)
 Query(request/response)

Echo (回送) request/response :

Timestamp (时戳) request/response:

Router (路由器) request/announcement:15/16

Netmask (掩码) request/reply:
8/0
13/14
17/18
Network Layer 4-108
ICMP: Internet Control Message Protocol
Type Code description
0
3
3
3
3
3
3
4
8
9
10
11
12
0
0
1
2
3
6
7
0
0
0
0
0
0
echo reply (ping)
destination network unreachable
destination host unreachable
destination protocol unreachable
destination port unreachable
destination network unknown
destination host unknown
source quench (congestion control - not used)
echo request (ping)
route advertisement
router discovery
TTL expired
bad IP header
Network Layer 4-109
Traceroute and ICMP
 Source sends series of UDP segments to destination



First has TTL =1
Second has TTL=2, etc.
Unlikely port number
 When nth datagram arrives to nth router:



Router discards datagram
And sends to source an ICMP message (type 11, code 0)
Message includes name of router& IP address
Network Layer 4-110
Traceroute and ICMP
 When ICMP message arrives, source calculates RTT
 Traceroute does this 3 times
Stopping criterion:
 UDP segment eventually arrives at destination host
 Destination returns ICMP “host unreachable” packet
(type 3, code 3)
 When source gets this ICMP, stops.
Network Layer 4-111
ICMP:request/reply
Yes. The path is nice!
Host B is OK?
B
A
type=8
Echo Request
Echo
Reply
type=0
Ping & Traceroute
Network Layer 4-112
Tracert
Network Layer 4-113
Network Layer 4-114
Chapter 4: Network Layer
 4. 1 Introduction
 4.2 Virtual circuit and
datagram networks
 4.3 What’s 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
multicast routing
Network Layer 4-115
IPv6
 Initial motivation: IPv4 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-116
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
Network Layer 4-117
IPv6 Address
 Examples

2007:1022:0000::0001:0000:0000:0000:1234

2007:1022: 1::1234

::00EC:A0BF:FFFF
 How to map IPv4 address to IPv6 address?
IPV4: 202.197.10.1
IPV6: ?
Network Layer 4-118
Header: IPv4 vs. IPv6
Network Layer 4-119
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-120
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
Network Layer 4-121
Tunneling
Logical view:
Physical view:
E
F
IPv6
IPv6
IPv6
A
B
E
F
IPv6
IPv6
IPv6
IPv6
A
B
IPv6
tunnel
IPv4
IPv4
Network Layer 4-122
Tunneling
Logical view:
Physical view:
tunnel
A
B
IPv6
IPv6
A
B
C
IPv6
IPv6
IPv4
Flow: X
Src: A
Dest: F
data
A-to-B:
IPv6
E
F
IPv6
IPv6
D
E
F
IPv4
IPv6
IPv6
Src:B
Dest: E
Src:B
Dest: E
Flow: X
Src: A
Dest: F
Flow: X
Src: A
Dest: F
data
data
B-to-C:
IPv6 inside
IPv4
B-to-C:
IPv6 inside
IPv4
Flow: X
Src: A
Dest: F
data
E-to-F:
IPv6
Network Layer 4-123
Chapter 4: Network Layer
 4. 1 Introduction
 4.2 Virtual circuit and
datagram networks
 4.3 What’s 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
multicast routing
Network Layer 4-124
Interplay between routing, forwarding
routing algorithm
local forwarding table
header value output link
0100
0101
0111
1001
3
2
2
1
value in arriving
packet’s header
0111
1
3 2
Network Layer 4-125
Graph abstraction
5
2
U
2
1
Graph: G = (N,E)
v
x
3
w
3
1
5
Z
1
y
2
N = set of routers = { u, v, w, x, y, z }
E = set of links ={ (u,v), (u,x), (v,x), (v,w), (x,w), (x,y), (w,y), (w,z), (y,z) }
Remark: Graph abstraction is useful in other network contexts
Example: P2P, where N is set of peers and E is set of TCP connections
Network Layer 4-126
Graph abstraction: costs
5
2
U
v
2
1
x
• c(x, y) = cost of link (x, y)
3
w
3
1
5
1
y
2
- e.g., c(w,z) = 5
z
• cost could always be 1, or
inversely related to bandwidth,
or inversely related to congestion
Cost of path (x1, x2, x3,…, xp) = c(x1, x2) + c(x2, x3) + … + c(xp-1, xp)
Question: What’s the least-cost path between u and z ?
Routing algorithm: algorithm that finds the least-cost path
Network Layer 4-127
Routing Algorithm classification
Global:
 all routers have complete topology, link cost info
 “link state” algorithms
Decentralized:
 router knows physically-connected neighbors, link
costs to neighbors
 iterative process of computation, exchange of info
with neighbors
 “distance vector” algorithms
Network Layer 4-128
Routing Algorithm classification
Static:
 routes change slowly over time
Dynamic:
 routes change more quickly
periodic update
 in response to link cost changes

Network Layer 4-129
Chapter 4: Network Layer
 4. 1 Introduction
 4.2 Virtual circuit and
datagram networks
 4.3 What’s 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
multicast routing
Network Layer 4-130
A Link-State Routing Algorithm
Dijkstra’s algorithm
 net topology, link costs
known to all nodes
 accomplished via “link
state broadcast”
 all nodes have same
info.
 computes least cost paths
from one node (‘source”) to
all other nodes
 gives forwarding table
for that node
 iterative: after k
iterations, know least cost
path to k destination’s
Notation:
 c(x,y): link cost from node
x to y; = ∞ if not direct
neighbors
 D(v): current value of cost
of path from source to
dest. v
 p(v): predecessor node
along path from source to v
 N': set of nodes whose
least cost path definitively
known
Network Layer 4-131
Dijsktra’s Algorithm
1 Initialization:
2 N' = {u}
3 for all nodes v
4
if v adjacent to u
5
then D(v) = c(u,v)
6
else D(v) = ∞
7
8 Loop
9 find w not in N' such that D(w) is a minimum
10 add w to N'
11 update D(v) for all v adjacent to w and not in N' :
12
D(v) = min( D(v), D(w) + c(w,v) )
13 /* new cost to v is either old cost to v or known
14 shortest path cost to w plus cost from w to v */
15 until all nodes in N'
Network Layer 4-132
Dijkstra’s algorithm: example
Step
0
1
2
3
4
5
N'
u
ux
uxy
uxyv
uxyvw
uxyvwz
D(v),p(v) D(w),p(w)
2,u
5,u
2,u
4,x
2,u
3,y
3,y
D(x),p(x)
1,u
D(y),p(y)
∞
2,x
D(z),p(z)
∞
∞
4,y
4,y
4,y
5
2
U
3
v
2
1
x
w
3
1
5
Z
1
y
2
Network Layer 4-133
Step
0
1
2
3
4
5
N'
u
ux
uxy
uxyv
uxyvw
uxyvwz
D(v),p(v) D(w),p(w)
2,u
5,u
2,u
4,x
2,u
3,y
3,y
D(x),p(x)
1,u
D(y),p(y)
∞
2,x
D(z),p(z)
∞
∞
4,y
4,y
4,y
Step 0
D(z) = ∞
Step 1
D(z) = ∞
Step 2
D(z) = min( D(z), D(y) + c(y, z) )= min(∞, 2 + c(y, z) )= 4
Step 3
D(z) = min( D(z), D(v) + c(v, z) )= min(4, 2 + c(v, z) )= 4
Step 4
D(z) = min( D(z), D(w) + c(w, z) )= min(4, 4 + 5 )= 4
5
2
U
v
2
1
x
3
w
3
1
5
1
y
2
Z
Network Layer 4-134
Dijkstra’s algorithm: example (2)
Resulting shortest-path tree from U:
v
w
u
z
x
y
Resulting forwarding table in u:
destination
link
v
x
(u,v)
(u,x)
y
(u,x)
w
(u,x)
z
(u,x)
Network Layer 4-135
Dijkstra’s algorithm, discussion
Algorithm complexity: n nodes
 each iteration: need to check all nodes, w, not in N
 n(n+1)/2 comparisons: O(n2)
 more efficient implementations possible: O(nlogn)
Oscillations possible:
 e.g., link cost = amount of carried traffic
D
1
1
0
A
0 0
C
e
1+e
B
e
initially
2+e
D
0
1
A
1+e 1
C
0
B
0
… recompute
routing
0
D
1
A
0 0
2+e
B
C 1+e
… recompute
2+e
D
0
A
1+e 1
C
0
B
e
… recompute
Network Layer 4-136
Chapter 4: Network Layer
 4. 1 Introduction
 4.2 Virtual circuit and
datagram networks
 4.3 What’s 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
multicast routing
Network Layer 4-137
Distance Vector Algorithm
Bellman-Ford Equation (dynamic programming)
Define
dx(y) := cost of least-cost path from x to y
Then, we have
dx(y) = min
{c(x,v) + dv(y) }
v
where min is taken over all neighbors v of x
Network Layer 4-138
Bellman-Ford example
Clearly, dv(z) = 5, dx(z) = 3, dw(z) = 3
5
2
U
B-F equation says:
3
v
2
1
x
w
Z
1
3
1
5
y
2
du(z) = min { c(u,v) + dv(z),
c(u,x) + dx(z),
c(u,w) + dw(z) }
= min {2 + 5,
1 + 3,
5 + 3} = 4
Node that achieves minimum is next
hop in shortest path ➜ forwarding table
Network Layer 4-139
From
V
W
X
u 2
5
1
c(u,x) + dx(z),
v 0
3
2
c(u,w) + dw(z) }
w 3
0
3
x 2
3
0
y 3
1
1
z 5
5
3
U’s route information
from his neighbors
(dynamically):
v, w, x
du(z) = min { c(u,v) + dv(z),
U的转发表
距离
下一跳
u
0
-
v
2
v
w
x
y
5
1
2
w,v
x
x
z
4
x
Network Layer 4-140
Distance vector algorithm
Basic idea:
 Each node periodically sends its own distance
vector estimate to neighbors
 When a node x receives new DV estimate from
neighbor, it updates its own DV using B-F equation:
Dx(y) ← minv{c(x,v) + Dv(y)}
for each node y ∊ N
 Under minor, natural conditions, the estimate
Dx(y) converge to the actual least cost dx(y)
Network Layer 4-141
Distance Vector Algorithm (5)
Iterative, asynchronous:
each local iteration caused by:
 local link cost change
 DV update message from
neighbor
Distributed:
 each node notifies neighbors
only when its DV changes

neighbors then notify their
neighbors if necessary
Each node:
wait for (change in local link
cost or msg from neighbor)
recompute estimates
if DV to any destination has
changed, notify neighbors
Network Layer 4-142
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)}
= min{2+0 , 7+1} = 2
node x table
cost to
x y z
cost to
x y z
from
from
x 0 2 7
y ∞∞ ∞
z ∞∞ ∞
node y table
cost to
x y z
Dx(z) = min{c(x,y) +
Dy(z), c(x,z) + Dz(z)}
= min{2+1 , 7+0} = 3
x 0 2 3
y 2 0 1
z 7 1 0
x ∞ ∞ ∞
y 2 0 1
z ∞∞ ∞
node z table
cost to
x y z
from
from
x
x ∞∞ ∞
y ∞∞ ∞
z 71 0
time
2
y
7
1
z
Network Layer 4-143
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)}
= min{2+0 , 7+1} = 2
node x table
cost to
x y z
x ∞∞ ∞
y ∞∞ ∞
z 7 1 0
from
from
from
from
x 0 2 7
y 2 0 1
z 7 1 0
cost to
x y z
x 0 2 7
y 2 0 1
z 3 1 0
x 0 2 3
y 2 0 1
z 3 1 0
cost to
x y z
x 0 2 3
y 2 0 1
z 3 1 0
x
2
y
7
1
z
cost to
x y z
from
from
from
x ∞ ∞ ∞
y 2 0 1
z ∞∞ ∞
node z table
cost to
x y z
x 0 2 3
y 2 0 1
z 7 1 0
cost to
x y z
cost to
x y z
from
from
x 0 2 7
y ∞∞ ∞
z ∞∞ ∞
node y table
cost to
x y z
cost to
x y z
Dx(z) = min{c(x,y) +
Dy(z), c(x,z) + Dz(z)}
= min{2+1 , 7+0} = 3
x 0 2 3
y 2 0 1
z 3 1 0
time
Network Layer 4-144
V-D路由算法

算法原理:
 让每个路由器动态计算并维护一张距离向量表,表中为
从某节点能到达其他节点的最佳路径代价和输出接口;
具体地:
(1)每个路由器维持到各个已知目的节点的距离(distance)
(2)向每个邻居路由器周期宣告自己知道的网络信息
(3)收到邻居送来的信息进行路由计算
(4)然后把学来的路由再告诉其他邻居
 如果从本路由器不能到某目的地,则其代价为无穷大;
 路径代价的度量单位可以是时间延迟、物理距离、经过
的路由器个数(跳数)或其它参数;
Network Layer 4-145
V-D算法原理图示:
 每隔一段时间(如30
秒)计算到相邻路由器代价;
 每隔一段时间(如30
秒)相邻路由器之间交换一次
向量表,并据此计算并更新自己的路由表;
Network Layer 4-146
Distance Vector: link cost changes
Link cost changes:
 node detects local link cost change
 updates routing info, recalculates
distance vector
 if DV changes, notify neighbors
1
x
y
4
50
1
z
At time t0, y detects the link-cost change, updates its DV,
and informs its neighbors.
At time t1, z receives the update from y and updates its table.
It computes a new least cost to x and sends its neighbors its DV.
At time t2, y receives z’s update and updates its distance table.
y’s least costs do not change and hence y does not send any message to z.
“good news travels fast”
Network Layer 4-147
Convergence
“Bad news travels
slow”
Network Layer 4-148
Distance Vector: link cost changes
Link cost changes:
 good news travels fast
 bad news travels slow - “count to
infinity” problem!
 44 iterations before algorithm
stabilizes:
60
x
4
y
50
1
z
Poisoned reverse:
If Z routes through Y to get to X :
Z tells Y its (Z’s) distance to X is infinite (so Y
won’t route to X via Z)
will this completely solve count to infinity problem?
Network Layer 4-149
V-D路由算法-Still have problem?
 采用水平分割法,若B路由器出故障,A-B-C或者A-
B-D可确保不再发生问题,但不幸的是C听说D可以2跳
到达A,D亦听说可通过C到A,因此,下一次交换均将
到A的距离增加到3。。。直至无穷大。
D
C 
B 
A 
 1979年以后,ARPANet就以链路-状态算法取代它。
Network Layer 4-150
V-D路由算法特点:
 该算法思想非常简单,基于该算法的路由协议(如RIP
)易配置、维护和使用。
 最大问题是收敛慢,且在收敛过程中,有可能产生路由
循环。
 不适合于大型、复杂的网络。
 只考虑了简单的距离(代价)因素,没有考虑物理链路
带宽;
 交换的是相邻路由器之间的部分路由信息,信息不充分
,路由器并未获知全网的结构以及各节点状态。
Network Layer 4-151
Comparison of LS and DV algorithms
Message complexity
 LS: with n nodes, E links, O(nE) messages sent
 DV: exchange between neighbors only

convergence time varies
Speed of Convergence
 LS: O(n2) algorithm requires O(nE) messages

may have oscillations
 DV: convergence time varies
may be routing loops
 count-to-infinity problem

Network Layer 4-152
Comparison of LS and DV algorithms
Robustness: what happens if router malfunctions?
LS:
 node can advertise incorrect link cost
 each node computes only its own table
DV:
DV node can advertise incorrect path cost
 each node’s table used by others
 error propagate through network

Network Layer 4-153
Chapter 4: Network Layer
 4. 1 Introduction
 4.2 Virtual circuit and
datagram networks
 4.3 What’s 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
multicast routing
Network Layer 4-154
Hierarchical Routing
Our routing study thus far - idealization
 all routers identical
 network “flat”
… not true in practice
scale: with 200 million
destinations:
 can’t store all destination’s
in routing tables!
 routing table exchange
would swamp links!
administrative autonomy
 internet = network of
networks
 each network administrator
may want to control routing
in its own network
Network Layer 4-155
Hierarchical Routing
 aggregate routers into
regions, “autonomous
systems” (AS)
 routers in the same
AS run same routing
protocol


Gateway router
 Direct link to router in
another AS
“intra-AS” routing
protocol
routers in different AS
can run different intraAS routing protocol
Network Layer 4-156
Autonomous System
 AS (自治系统)
Network Layer 4-157
Interconnected ASes
3c
3a
3b
AS3
1a
2a
1c
1d
1b
Intra-AS
Routing
algorithm
2c
AS2
AS1
Inter-AS
Routing
algorithm
Forwarding
table
2b
 forwarding table
configured by both
intra- and inter-AS
routing algorithm


intra-AS sets entries
for internal
destinations
inter-AS & Intra-As
sets entries for
external destinations
Network Layer 4-158
Inter-AS tasks
AS1 must:
1. learn which destinations
reachable through AS2,
which through AS3
2. propagate this
reachability info to all
routers in AS1
Job of inter-AS routing!
 suppose router in AS1
receives datagram
destination outside of
AS1
 router should
forward packet to
gateway router, but
which one?
3c
3b
3a
AS3
1a
2a
1c
1d
1b
2c
AS2
2b
AS1
Network Layer 4-159
Example: Setting forwarding table in router 1d
 suppose AS1 learns (via inter-AS protocol) that subnet
x reachable via AS3 (gateway 1c) but not via AS2.
 inter-AS protocol propagates reachability info to all
internal routers.
 router 1d determines from intra-AS routing info that
its interface I is on the least cost path to 1c.
 installs forwarding table entry (x,I)
x
3c
3a
3b
AS3
1a
2a
1c
1d
1b AS1
2c
2b
AS2
Network Layer 4-160
Example: Choosing among multiple ASes
 now suppose AS1 learns from inter-AS protocol that
subnet x is reachable from AS3 and from AS2.
 to configure forwarding table, router 1d must
determine towards which gateway it should forward
packets for dest x.
 this is also job of inter-AS routing protocol!
x
3c
3a
3b
AS3
1a
2a
1c
1d
1b
2c
AS2
2b
AS1
Network Layer 4-161
Example: Choosing among multiple ASes
 now suppose AS1 learns from inter-AS protocol that
subnet x is reachable from AS3 and from AS2.
 to configure forwarding table, router 1d must
determine towards which gateway it should forward
packets for dest x.
 this is also job of inter-AS routing protocol!
 hot potato routing: send packet towards closest of
two routers.
Learn from inter-AS
protocol that subnet
x is reachable via
multiple gateways
Use routing info
from intra-AS
protocol to determine
costs of least-cost
paths to each
of the gateways
Hot potato routing:
Choose the gateway
that has the
smallest least cost
Determine from
forwarding table the
interface I that leads
to least-cost gateway.
Enter (x,I) in
forwarding table
Network Layer 4-162
Chapter 4: Network Layer
 4. 1 Introduction
 4.2 Virtual circuit and
datagram networks
 4.3 What’s 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
multicast routing
Network Layer 4-163
Intra-AS Routing
 also known as Interior Gateway Protocols (IGP)
 most common Intra-AS routing protocols:

RIP: Routing Information Protocol

OSPF: Open Shortest Path First

IGRP: Interior Gateway Routing Protocol (Cisco
proprietary)
Network Layer 4-164
Chapter 4: Network Layer
 4. 1 Introduction
 4.2 Virtual circuit and
datagram networks
 4.3 What’s 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
multicast routing
Network Layer 4-165
RIP ( Routing Information Protocol)
 distance vector algorithm
 included in BSD-UNIX Distribution in 1982
 distance metric: # of hops (max = 15 hops)
From router A to subsets:
u
v
A
z
C
B
D
w
x
y
destination hops
u
1
v
2
w
2
x
3
y
3
z
2
Network Layer 4-166
RIP advertisements
 distance vectors: exchanged among
neighbors every 30 sec via Response
Message (also called advertisement)
 ech advertisement: list of up to 25
destination nets within AS
Network Layer 4-167
RIP: Example
z
w
A
x
D
B
y
C
Destination Network
w
y
z
x
….
Next Router
Num. of hops to dest.
….
....
A
B
B
--
2
2
7
1
Routing table in D
Network Layer 4-168
RIP: Example
Dest
w
x
z
….
Next
C
…
w
hops
1
1
4
...
A
Advertisement
from A to D
z
x
Destination Network
w
y
z
x
….
D
B
C
y
Next Router
Num. of hops to dest.
….
....
A
B
B A
--
Routing table in D
2
2
7 5
1
Network Layer 4-169
RIP: Link Failure and Recovery
If no advertisement heard after 180 sec -->
neighbor/link declared dead
 routes via neighbor invalidated
 new advertisements sent to neighbors
 neighbors in turn send out new advertisements (if
tables changed)
 link failure info quickly (?) propagates to entire net
 poison reverse used to prevent ping-pong loops
(infinite distance = 16 hops)
Network Layer 4-170
RIP Table processing
 RIP routing tables managed by application-level
process called route-d (daemon)
 advertisements sent in UDP packets, periodically
repeated
routed
routed
Transprt
(UDP)
network
(IP)
link
physical
Transprt
(UDP)
forwarding
table
forwarding
table
network
(IP)
link
physical
Network Layer 4-171
Chapter 4: Network Layer
 4. 1 Introduction
 4.2 Virtual circuit and
datagram networks
 4.3 What’s 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
multicast routing
Network Layer 4-172
OSPF (Open Shortest Path First)
 “open”: publicly available
 uses Link State algorithm
 LS packet dissemination
 topology map at each node
 route computation using Dijkstra’s algorithm
 OSPF advertisement carries one entry per neighbor
router
 advertisements disseminated to entire AS (via
flooding)

carried in OSPF messages directly over IP (rather than TCP
or UDP
Network Layer 4-173
OSPF “advanced” features (not in RIP)
 security: all OSPF messages authenticated (to




prevent malicious intrusion)
multiple same-cost paths allowed (only one path in
RIP)
For each link, multiple cost metrics for different
TOS (e.g., satellite link cost set “low” for best effort;
high for real time)
integrated uni- and multicast support:
 Multicast OSPF (MOSPF) uses same topology data
base as OSPF
hierarchical OSPF in large domains.
Network Layer 4-174
Hierarchical OSPF
Network Layer 4-175
Hierarchical OSPF
 two-level hierarchy: local area, backbone.
Link-state advertisements only in area
 each nodes has detailed area topology; only know
direction (shortest path) to nets in other areas.
 area border routers: “summarize” distances to nets
in own area, advertise to other Area Border routers.
 backbone routers: run OSPF routing limited to
backbone.
 boundary routers: connect to other AS’s.

Network Layer 4-176
Chapter 4: Network Layer
 4. 1 Introduction
 4.2 Virtual circuit and
datagram networks
 4.3 What’s 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
multicast routing
Network Layer 4-177
Internet inter-AS routing: BGP
 BGP (Border Gateway Protocol): the de
facto standard
 BGP provides each AS a means to:
1.
2.
3.
Obtain subnet reachability information from
neighboring ASs.
Propagate reachability information to all ASinternal routers.
Determine “good” routes to subnets based on
reachability information and policy.
 allows subnet to advertise its existence to
rest of Internet: “I am here”
Network Layer 4-178
BGP basics
 pairs of routers (BGP peers) exchange routing info
over semi-permanent TCP connections: BGP sessions
 BGP sessions need not correspond to physical
links.
 when AS2 advertises prefix to AS1:
 AS2 promises it will forward any addresses
datagrams towards that prefix.
 AS2 can aggregate prefixes in its advertisement
eBGP session
3c
3a
3b
AS3
1a
AS1
iBGP session
2a
1c
1d
1b
2c
AS2
2b
Network Layer 4-179
Distributing reachability info
 using eBGP session between 3a and 1c, AS3 sends
prefix reachability info to AS1.
 1c can then use iBGP do distribute new prefix
info to all routers in AS1
 1b can then re-advertise new reachability info
to AS2 over 1b-to-2a eBGP session
 when router learns of new prefix, creates entry
for prefix in its forwarding table.
eBGP session
3c
3a
3b
AS3
1a
AS1
iBGP session
2a
1c
1d
1b
2c
AS2
2b
Network Layer 4-180
Path attributes & BGP routes
 advertised prefix includes BGP attributes.
 prefix + attributes = “route”
 two important attributes:
 AS-PATH: contains ASs through which prefix
advertisement has passed: e.g, AS 67, AS 17
 NEXT-HOP: indicates specific internal-AS router
to next-hop AS. (may be multiple links from
current AS to next-hop-AS)
 when gateway router receives route
advertisement, uses import policy to
accept/decline.
Network Layer 4-181
BGP route selection
 router may learn about more than 1 route
to some prefix. Router must select route.
 elimination rules:
1.
2.
3.
4.
local preference value attribute: policy
decision
shortest AS-PATH
closest NEXT-HOP router: hot potato routing
additional criteria
Network Layer 4-182
BGP messages
 BGP messages exchanged using TCP.
 BGP messages:
OPEN: opens TCP connection to peer and
authenticates sender
 UPDATE: advertises new path (or withdraws old)
 KEEPALIVE keeps connection alive in absence of
UPDATES; also ACKs OPEN request
 NOTIFICATION: reports errors in previous msg;
also used to close connection

Network Layer 4-183
BGP routing policy
legend:
B
W
X
A
provider
network
customer
network:
C
Y
 A,B,C are provider networks
 X,W,Y are customer (of provider networks)
 X is dual-homed: attached to two networks
X does not want to route from B via X to C
 .. so X will not advertise to B a route to C

Network Layer 4-184
BGP routing policy (2)
legend:
B
W
X
A
provider
network
customer
network:
C
Y
 A advertises path AW to B
 B advertises path BAW to X
 Should B advertise path BAW to C?
 No
way! B gets no “revenue” for routing CBAW
since neither W nor C are B’s customers
 B wants to force C to route to w via A
 B wants to route only to/from its customers!
Network Layer 4-185
Why different Intra- and Inter-AS routing ?
Policy:
 Inter-AS: admin wants control over how its traffic
routed, who routes through its net.
 Intra-AS: single admin, so no policy decisions needed
Scale:
 hierarchical routing saves table size, reduced update
traffic
Performance:
 Intra-AS: can focus on performance
 Inter-AS: policy may dominate over performance
Network Layer 4-186
Chapter 4: Network Layer
 4. 1 Introduction
 4.2 Virtual circuit and
datagram networks
 4.3 What’s 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
multicast routing
Network Layer 4-187
Broadcast Routing
 deliver packets from source to all other nodes
 source duplication is inefficient:
duplicate
duplicate
creation/transmission
R1
R1
duplicate
R2
R2
R3
R4
source
duplication
R3
R4
in-network
duplication
 source duplication: how does source
determine recipient addresses?
Network Layer 4-188
In-network duplication
 flooding: when node receives brdcst pckt,
sends copy to all neighbors

Problems: cycles & broadcast storm
 controlled flooding: node only brdcsts pkt
if it hasn’t brdcst same packet before
Node keeps track of pckt ids already brdcsted
 Or reverse path forwarding (RPF): only forward
pckt if it arrived on shortest path between
node and source

 spanning tree
 No redundant packets received by any node
Network Layer 4-189
Spanning Tree
 First construct a spanning tree
 Nodes forward copies only along spanning
tree
A
B
c
F
A
E
B
c
D
F
G
(a) Broadcast initiated at A
E
D
G
(b) Broadcast initiated at D
Network Layer 4-190
Spanning Tree: Creation
 Center node
 Each node sends unicast join message to center
node

Message forwarded until it arrives at a node already
belonging to spanning tree
A
A
3
B
c
4
E
F
1
2
B
c
D
F
5
E
D
G
G
(a) Stepwise construction
of spanning tree
(b) Constructed spanning
tree
Network Layer 4-191
Multicast Routing: Problem Statement
 Goal: find a tree (or trees) connecting
routers having local mcast group members



tree: not all paths between routers used
source-based: different tree from each sender to rcvrs
shared-tree: same tree used by all group members
Shared tree
Source-based trees
Approaches for building mcast trees
Approaches:
 source-based tree: one tree per source
shortest path trees
 reverse path forwarding

 group-shared tree: group uses one tree
 minimal spanning (Steiner)
 center-based trees
…we first look at basic approaches, then specific
protocols adopting these approaches
Shortest Path Tree
 mcast forwarding tree: tree of shortest
path routes from source to all receivers

Dijkstra’s algorithm
S: source
LEGEND
R1
1
2
R4
R2
3
R3
router with attached
group member
5
4
R6
router with no attached
group member
R5
6
R7
i
link used for forwarding,
i indicates order link
added by algorithm
Reverse Path Forwarding
 rely on router’s knowledge of unicast
shortest path from it to sender
 each router has simple forwarding behavior:
if (mcast datagram received on incoming link
on shortest path back to center)
then flood datagram onto all outgoing links
else ignore datagram
Reverse Path Forwarding: example
S: source
LEGEND
R1
R4
router with attached
group member
R2
R5
R3
R6
R7
router with no attached
group member
datagram will be
forwarded
datagram will not be
forwarded
• result is a source-specific reverse SPT
– may be a bad choice with asymmetric links
Reverse Path Forwarding: pruning
 forwarding tree contains subtrees with no mcast
group members
 no need to forward datagrams down subtree
 “prune” msgs sent upstream by router with no
downstream group members
LEGEND
S: source
R1
router with attached
group member
R4
R2
P
R5
R3
R6
P
R7
P
router with no attached
group member
prune message
links with multicast
forwarding
Shared-Tree: Steiner Tree
 Steiner Tree: minimum cost tree
connecting all routers with attached group
members
 problem is NP-complete
 excellent heuristics exists
 not used in practice:
computational complexity
 information about entire network needed
 monolithic: rerun whenever a router needs to
join/leave

Center-based trees
 single delivery tree shared by all
 one router identified as “center” of tree
 to join:
edge router sends unicast join-msg addressed
to center router
 join-msg “processed” by intermediate routers
and forwarded towards center
 join-msg either hits existing tree branch for
this center, or arrives at center
 path taken by join-msg becomes new branch of
tree for this router

Center-based trees: an example
Suppose R6 chosen as center:
LEGEND
R1
3
R2
router with attached
group member
R4
2
R5
R3
1
R6
R7
1
router with no attached
group member
path order in which join
messages generated
Internet Multicasting Routing: DVMRP
 DVMRP: distance vector multicast routing
protocol, RFC1075
 flood and prune: reverse path forwarding,
source-based tree
RPF tree based on DVMRP’s own routing tables
constructed by communicating DVMRP routers
 no assumptions about underlying unicast
 initial datagram to mcast group flooded
everywhere via RPF
 routers not wanting group: send upstream prune
msgs

DVMRP: continued…
 soft state: DVMRP router periodically (1 min.)
“forgets” branches are pruned:
mcast data again flows down unpruned branch
 downstream router: reprune or else continue to
receive data

 routers can quickly regraft to tree

following IGMP join at leaf
 odds and ends
 commonly implemented in commercial routers
 Mbone routing done using DVMRP
Tunneling
Q: How to connect “islands” of multicast
routers in a “sea” of unicast routers?
physical topology
logical topology
 mcast datagram encapsulated inside “normal” (non-multicast-
addressed) datagram
 normal IP datagram sent thru “tunnel” via regular IP unicast to
receiving mcast router
 receiving mcast router unencapsulates to get mcast datagram
PIM: Protocol Independent Multicast
 not dependent on any specific underlying unicast
routing algorithm (works with all)
 two different multicast distribution scenarios :
Dense:
Sparse:
 group members
 # networks with group
densely packed, in
“close” proximity.
 bandwidth more
plentiful
members small wrt #
interconnected networks
 group members “widely
dispersed”
 bandwidth not plentiful
Consequences of Sparse-Dense Dichotomy:
Dense
 group membership by
Sparse:
 no membership until
routers assumed until
routers explicitly join
routers explicitly prune  receiver- driven
 data-driven construction
construction of mcast
on mcast tree (e.g., RPF)
tree (e.g., center-based)
 bandwidth and non bandwidth and non-groupgroup-router processing
router processing
profligate
conservative
PIM- Dense Mode
flood-and-prune RPF, similar to DVMRP but
 underlying unicast protocol provides RPF info
for incoming datagram
 less complicated (less efficient) downstream
flood than DVMRP reduces reliance on
underlying routing algorithm
 has protocol mechanism for router to detect it
is a leaf-node router
PIM - Sparse Mode
 center-based approach
 router sends join msg
to rendezvous point
(RP)

router can switch to
source-specific tree
increased performance:
less concentration,
shorter paths
R4
join
intermediate routers
update state and
forward join
 after joining via RP,

R1
R2
R3
join
R5
join
R6
all data multicast
from rendezvous
point
R7
rendezvous
point
PIM - Sparse Mode
sender(s):
 unicast data to RP,
which distributes down
RP-rooted tree
 RP can extend mcast
tree upstream to
source
 RP can send stop msg
if no attached
receivers

“no one is listening!”
R1
R4
join
R2
R3
join
R5
join
R6
all data multicast
from rendezvous
point
R7
rendezvous
point
Chapter 4: summary
 4. 1 Introduction
 4.2 Virtual circuit and
datagram networks
 4.3 What’s 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
Network Layer
4209
Virtual Circuit
VC number
22
12
1
Forwarding table in
northwest router:
Incoming interface
1
2
3
1
…
2
32
3
interface
number
Incoming VC #
12
63
7
97
…
Outgoing interface
3
1
2
3
…
Outgoing VC #
22
18
17
87
…
Routers maintain connection state information!
Network Layer 4-210
Virtual circuits: signaling protocols
 used to setup, maintain, and teardown Virtual Circuit
 used in ATM, frame-relay, X.25
 not used in today’s Internet
application
transport 5. Data flow begins
network 4. Call connected
data link 1. Initiate call
physical
6. Receive data application
3. Accept call
2. incoming call
transport
network
data link
physical
Network Layer 4-211
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-destination pair may take
different paths
application
transport
network
data link 1. Send data
physical
application
transport
network
2. Receive data
data link
physical
Network Layer 4-212
Forwarding table
Destination Address Range
4 billion
possible entries ?
Link Interface
11001000 00010111 00010000 00000000
through
11001000 00010111 00010111 11111111
0
11001000 00010111 00011000 00000000
through
11001000 00010111 00011000 11111111
1
11001000 00010111 00011001 00000000
through
11001000 00010111 00011111 11111111
2
otherwise
3
Network Layer 4-213
Three types of switching fabrics
Network Layer 4-214
IP Address Format
IP Address ::= { <Network ID>, <Host ID>}
All network Ids are assigned by INIC, and the
host Ids are assigned by AS
Network Layer 4-215
IP Address: 点分十进制表示法
主机的 IP 地址
是 32 位二进制代码
每隔 8 位插入一个空格
以提高可读性
将每 8位的二进制数
转换为十进制数表示
readable!
10000000000010110000001100011111
10000000 00001011 00000011 00011111
128
11
3
31
128.11.3.31
Network Layer 4-216
IP 地址中的网络号字段和主机号字段
A 类地址
0
net-id
8 bit
B 类地址
host-id
24 bit
10
net-id
16 bit
C 类地址
host-id
16 bit
110
net-id
24 bit
D 类地址
1110
E 类地址
11110
host-id
8 bit
多播地址
保留为今后使用
Network Layer 4-217
Address “AND” mask= network ID
First 8 bits are network ID
Address 8.1.4.5
0000 1000 0000 0001 0000 0100 0000 0101
Mask
255.0.0.0
1111 1111 0000 0000 0000 0000 0000 0000
Result
8.0.0.0
0000 1000 0000 0000 0000 0000 0000 0000
Address
130.4.100.1
1000 0010 0000 0100 0110 0100 0000 0101
Mask
255.255.0.0
1111 1111 1111 1111 0000 0000 0000 0000
Result
130.4.0.0
1000 0010 0000 0100 0000 0000 0000 0000
First 16 bits are network ID
Network Layer 4-218
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
Subnet 2
223.1.1.1
223.1.2.1
223.1.1.2
223.1.1.4
223.1.1.3
223.1.2.9
223.1.3.27
Subnet 1
223.1.2.2
Subnet 3
223.1.3.2
223.1.3.1
223.1.1.1 = 11011111 00000001 00000001 00000001
223
1
1
1
Network Layer 4-219
IP Packet format:header and Data
分组表示符:用于判断
IP版本号:
通常5个字长
IPv4分段属于哪个分组
( 20个字节 )
用来说明分段在当前分组中的
3位优先级:
头部加数据最
位置(偏移量以8字节为单位)
D,T,R;两位未用
大:65536字节
校验:仅对头
部进行校验
DF=1:不可分段
MF=1:还有分段
生存期:用于限制分组生命
周期的计时器(缺省64)。
用于说明IP分组应被传送到的
选项:用于扩充协议功能。例如安
数据高层协议(TCP:
6, UDP: 17)
全性,记录路由,时间戳等
Network Layer
4220
ICMP (Internet Control Message Protocol)
 由于IP层采用数据报方式,当通信介质或路由器出现故障、
目的主机不可达、IP报文生存超时、路由器或通信拥塞等问
题出现时,IP报文无法正常到达目的主机,而源端却无法判
断发送失败的原因。
How to do?
让路由器向源主机报告差错情况-引入ICMP协议。
 ICMP协议是IP层协议的一部分;
 ICMP报文通过IP报文来传输。当路由器要发送ICMP报文
时,它会创建一个IP报文并将ICMP报文封装到IP报文的数
据区中,然后象普通IP报文一样通过因特网。
Network Layer 4-221
The
用于路由器或主机向出错数据报的源端
types of ICMP
packet
报告出错情况
目的端不可达(type = 3)
超时报文(type = 11)
差错报文
用于拥塞控制的源抑制报文和
参数出错(type = 12)
用于路径控制的重定向报文
ICMP报
文类型
源抑制报文(type = 4)
用于获得某些有关网络状态的信
重定向报文(type = 5)
控制报文
息,以便进行网络故障诊断和控
制
请求/应答
报文
回应请求/应答报文(type=8/0)
时戳请求/应答报文(type=13/14)
地址请求/应答报文(type=17/18)
Network Layer
4222
链路-状态(L-S)路由算法
1、工作原理:
-为每个路由器构造一张全网的拓扑结构图,图中包含
相邻节点之间的代价,使用最短路径算法为路由器计算
出到每一个节点的距离(代价)。

各自路由器之间发现邻居关系(确定位置)

计算链路传输时延

构造L-S报文

广播L-S报文

每个路由器计算到其他路由器的最短路径
Network Layer
4223
距离向量(V-D)路由算法

算法原理:
 让每个路由器动态计算并维护一张距离向量表,表中为
从某节点能到达其他节点的最佳路径代价和输出接口;
具体地:
(1)每个路由器维持到各个已知目的节点的距离(distance)
(2)向每个邻居路由器周期宣告自己知道的网络信息
(3)收到邻居送来的信息进行路由计算
(4)然后把学来的路由再告诉其他邻居
 如果从本路由器不能到某目的地,则其代价为无穷大;
 路径代价的度量单位可以是时间延迟、物理距离、经过
的路由器个数(跳数)或其它参数;
Network Layer
4224
Hierarchical routing
Network Layer
4225