Download Network Layer Functions Network Service Model

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

CAN bus wikipedia , lookup

Zigbee wikipedia , lookup

Peering wikipedia , lookup

AppleTalk wikipedia , lookup

Asynchronous Transfer Mode wikipedia , lookup

Net bias wikipedia , lookup

IEEE 802.1aq wikipedia , lookup

IEEE 1355 wikipedia , lookup

Distributed firewall wikipedia , lookup

Multiprotocol Label Switching wikipedia , lookup

Deep packet inspection wikipedia , lookup

Piggybacking (Internet access) wikipedia , lookup

Computer network wikipedia , lookup

Network tap wikipedia , lookup

Internet protocol suite wikipedia , lookup

Wake-on-LAN wikipedia , lookup

Airborne Networking wikipedia , lookup

List of wireless community networks by region wikipedia , lookup

UniPro protocol stack wikipedia , lookup

Routing in delay-tolerant networking wikipedia , lookup

Cracking of wireless networks wikipedia , lookup

Recursive InterNetwork Architecture (RINA) wikipedia , lookup

Zero-configuration networking wikipedia , lookup

Transcript
Internet Network Layer: Overview
‰ Network layer services
‰ IP – Internet Protocols: Format and Addressing schemes
‰ How Does Internet works? What’s inside a router?
‰ IP Subnetworking and routing
‰ ARP/DNS/NAT/DHCP/CIDR
‰ ICMP – for error control/report
‰ Goals:
‰ Routing principle: Hierarchical routing and path
selection*
¾Understand principles behind Network layer services
¾Instantiation and implementation in the Internet
‰ Routing Algorithms and Internet Routing Protocols
How the network layer moves a segment from the transport layer
of an origin host to the transport layer of the destination host ?
Network Layer
‰ IPv6 Protocol – header, addressing (a brief), migration
1
Network Layer
Network Layer Functions
‰ Transport packet from sending
End system
to receiving hosts via internet
Host #1
application
‰ Network layer protocols exist in
transport
network
data link
router
every host and router
physical
network
‰ Three important functions:
data link
physical
¾ path determination: route taken
by packets from source to destination
(Routing algorithms)
¾ forwarding: move packets from a
router’s input to a appropriate router’s
output
¾ call setup: some networks require
router call setup along path before
data flows (e.g., MPLS)
Network Layer
2
Network Service Model
Q: What’s service model for “channel” transporting
packets from sender to receiver?
router
network
data link
Variants (᧢ฆ) of delays
network
data link
physical
physical
network
data link
physical
network
data link
Connecting transport layers in
sending and receiving hosts
router
physical
application
transport
network
data link
physical
End system
Host #2
3
¾guaranteed bandwidth?
¾preservation of inter-packet timing (no jitter)?
Service
Abstraction
¾loss-free delivery?
(properties)
¾in-order delivery?
¾congestion feedback to sender? (protective CC)
virtual
Network-level
The most important
Service model
circuit
provided
abstraction
Ø
or
by network layer.
Determines end-to-end
Datagram
Characteristics of transporting
Data between network edges
Network Layer
?
?
?
4
(a review)
Virtual Circuit Networks
Virtual Circuits: via signaling protocols
™ “source-to-destination path” behaves much like “telephone circuit”
¾ performance-wise
¾ network actions along source-to-destination path
‰ Protocols used to exchange signaling messages
– setup, maintain (“initiation” mostly), and teardown VC
‰ Ex: ATM, frame-relay, X.25 VC-based networks (see chp.5)
‰ But . . . not used in today’s Internet
from VC to VC
‰ call setup for each call before data can flow
application
transport 5. Data flow begins
network 4. Call connected
data link 1. Initiate call
physical
‰ each packet carries VC identifier (not destination host OD)
‰ every router on source-destination path maintains “state” for each
passing (undergoing) connection (through it)
6. Receive data application
3. Accept call transport
2. incoming call network
data link
physical
œ transport-layer connection only involved two end systems
‰ Link and router resources (bandwidth, buffers) may be allocated to VC
¾ to get (real) circuit-like performance
(reserved)
Network Layer
5
VC setup at NL z connection setup at TL
Network Layer
Internet Architecture: TCP/IP Protocol suite
Datagram Networks: the Internet Model
(review)
(review)
AP Layer
‰ no call setup at network layer
‰ routers: no state about end-to-end connections
¾ no network-level concept of “connection” Æ out-of-order
‰ packets typically routed using destination host ID
¾ packets between same source-dest pair may take different
paths
application
transport
network
data link 1. Send data
physical
PING
TELNET
Segment
or
Datagram
SMTP
TCP
FTP
TRACE
ROUTE
SNMP
TP Layer
BOOTP
UTP
DNS
NTP
Based on
port #
Based on
protocol type
Packet
(Daragram)
application
transport
2. Receive data network
data link
physical
ICMP
ARP
IP
IGMP
Network Layer RARP
(Interface,
so-called SAP)
Frame
+
Bits
Network Layer
6
7
Network Layer
Based on
Protocol number
DATA LINK (e.g., Ethernet)
Ntwk Access Layer
Medium (Frames)
8
IP Overview - I
More on Internet Network (IP) layer
Network layer for host and router: datagram-oriented functions
• IP is designed to interconnect packet switched
(datagram)communication networks to form an internet.
Transport layer: TCP, UDP
Network
layer
1.IP protocol
• addressing conventions
• datagram format
• packet handling conventions
2.Routing protocols
• path selection
• Ex:RIP, OSPF, BGP
• It transmits blocks of data known as datagrams
received from IP’s upper-layer software to and from
hosts.
3.ICMP protocol
• error reporting
• router “signaling”
Build up
• IP provides best-effort or connectionless delivery.
routing
table
• IP is responsible for addressing.
• Two versions of IP: version 4 (RFC 791, currently) and
version 6 (RFC2373, 2460)
Link layer
physical layer
* Network information is distributed via
routing protocols.
9
Network Layer
10
IP Overview - II
IP Packet/datagram Format
Bit
0
4
8
16
Version
IHL
Type-of-service
Total length
Identification
Flags
Fragment offset
Time-to-live
Protocol
Header checksum
SourceIP
Address
Source
address
DestinationIP
Address
Destination
address
Padding
IP Option ȐIF anyȑ
• IP’s main function is to provide for the
interconnection of subnetworks to form an
internet in order to pass data.
Data (from TP layer)
• Summary of IP functions :
–
–
–
–
Network Layer
31
20 bytes
(IHL = 5)
Network Layer
Basic unit for data transfer (format, encapsulation)
Addressing
Routing (supporting packet forwarding)
Fragmentation of packets/datagrams
IP over Ethernet
Ethernet frame
Dest MAC
6 bytes
SRC MAC TYPE
6 bytes
2 bytes
IP Header + Data
46~1500 bytes
CRC
4 bytes
(MAC Address)
64(min) ~ 1518(max) bytes
11
Network Layer
12
IPv4 Header - TTL
IP datagram format – an Overview
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
32 bits
type of
ver head.
len service
length
fragment
16-bit identifier flgs
offset
time to upper
Internet
layer
live
checksum
VERS HLEN Service Type
total datagram
length (bytes)
HLEN
Service Type
Identification
for
fragmentation/
reassembly
Identification
Time
to Live
Protocol
Time to Live
Flags Header Checksum
Fragment Offset
a datagram is allowed to stay on the network.
(A 8-bit field, Max TTL = 255.)
32 bit destination IP address
data
(variable length,
typically a TCP
or UDP segment)
Total Length
Flags
Fragment Offset
Time-to-live — Indicating the amount of time (in second) that
32 bit source IP address
Options (if any)
Total Length
E.g. timestamp,
record route
taken, specify
list of routers
to visit.
Network Layer
• A datagram or some of its fragments may loop indefinitely
through the internet when dynamic or alternate routing is used
• The ψlifetimeω should be a true measure of time. This requires
some global clocking mechanism - estimating exact time is difficult.
• A simple way to implement lifetime is to use a hop count.
The initial is set by the packet originator and it varies.
13
Network Layer
Time to Live (TTL)
14
IPv4 Header Checksum
• IP header maintains a counter that gradually decrements
down to zero, at which point the datagram is discarded.
This keeps packets from looping endlessly.
VERS HLEN Service Type
HLEN
Service Type
Identification
Identification
Time
to Live
Protocol
• Rules:
Total Length
Flags
Total Length
Fragment Offset
Flags Header Checksum
Fragment Offset
Header Checksum
- Whenever a host injects a datagram into the internet, it
sets a maximum time that the datagram should survive
• Checksum ~ to ensure the integrity of the IP header (RFC 1071)
• Calculated over IP header only ((5 ~ 15) x 32-bit in total
since HLEN = 4-bit long. Can you see it ? )
• Each router will recompute the checksum while forwarding a DG.
- Router decrements TTL by 1 when processes the datagram
- Router decrements TTL by the seconds when the datagram
remained inside the router waiting for service
- Router discard the datagram (remove it from the internet) and
Why ? Because TTL is changed by each router the DG traverses.
sends error message (ICMP) back to the source whenever
How ? (refer to : RFC 1141)
TTL = 0 (Î the packet/datagram expired)
Network Layer
15
Network Layer
16
Checksum (CKS) Computing
Error Checking by Checksum (CKS)
• In sending station :
• In receiving station :
- CKS = 0 initially for an outgoing DG
- Calculate the 16-bit one’s complement sum of the header
(i.e., the entire header is considered a sequence of 16-bit words)
and store the 16-bit one’s complement of the sum in CKS field
• Example (downsize to 8-bit)
CKS = 00000000 (initial)
Header = 10010110 11001000
01000010
- When an IP DG is received, the 16-bit one’s complement sum
of the header is re-calculated
- CKS { all 1’s, if no error (since the receiver’s CKS calculation
contains the CKS stored by the sender)
- Declare checksum error if CKS z all 1’s, and IP discards the
received DG (No error message is generated upon error detected.
It is up to the higher layers to somehow detect the missing
datagram and retransmit it.)
00010110 . . .
• Example (cont’d) – if no error
CKS = (01101001 + 00110111 + 10111101 + 11101001)’
CKS_new = ((data_1)’ + (data_2)’ + . . . + (CKS_old)’)’
= . . .
=
= . . .
11110101
= 11111111
Network Layer
17
Network Layer
A Note on IP Address
IP Addressing
Addressing
IP
Interface addresses
• Examples
223.1.1.1
‰ IP address: 32-bit identifier for
host and router’s interface
223.1.2.1
223.1.1.2
‰ interface: connection between
223.1.2.9
223.1.1.4
host, router and physical link
223.1.2.2
223.1.1.3 223.1.3.27
¾ Routers - typically have
multiple interfaces
¾ Host - may have multiple
223.1.3.2
223.1.3.1
interfaces
Æ IP addresses associated
with interface(s), not
223.1.1.1 = 11011111 00000001 00000001 00000001
host or router
223
Network Layer
• IP address Structure
- Divided 32-bit into 4 octets of binary
- Use Dotted-decimal representation
18
1
1
• An IP address does not identify a specific computer.
Instead, each IP address identifies a connection between a
computer and a network. A computer with multiple
network connections (e.g., a router) must be assigned one
IP address for each connection.
NetID
• Global authority (IANA) assigns unique prefix to network
• Local administrator assigns unique suffix to host (interface)
1
19
Network Layer
HostID
20
IP Addressing (cont’d)
Routers Interconnect Networks
Network addresses
‰ IP address:
¾ network part (high order
bits)
¾ host part (low order bits)
‰ What’s a network ? (from IP
address perspective)
¾ device interfaces with
same network part of IP
address
¾ can physically reach
each other without
intervening router
223.1.1.1
223.1.1.0/24
223.1.1.2
223.1.1.4
223.1.2.1
223.1.2.9
223.1.3.27
223.1.1.3
223.1.3.0/24
223.1.2.0/24
223.1.2.2
LAN
Interconnected
system consisting ÆÆ
of six networks.
island
223.1.9.2
223.1.7.0
223.1.7.1
223.1.8.0
223.1.2.6
223.1.3.27
223.1.2.2
223.1.3.1
223.1.3.2
Network Layer
IP
IP Addressing:
Addressing: Classful
Classful and
and Classless
Classless
22
Classes of Original IP Address
‰Classful addressing (RFC 791)
• Primary IP Classes : Class A, B, and C
¾ Fixed number of bits for network and host portions
¾ inefficient use (giving out) of address space (IP address exhaustion)
• e.g., class B net allocated enough addresses for 65K hosts,
Class A
7-bit network address
0
even if only 2K hosts in that network Å waste address space
Last three bytes
(0000000) = 0 ~ (1111111) = 27 – 1
"
‰ Class A : 0.0.0.0 ~ 127.255.255.255
¾ network portion of address of arbitrary length
¾ address format: a.b.c.d/x , where x is the number of leading bits
in network portion of address
– Networks (Max) : 1.0.0.0 ~ 126.0.0.0 (128 - 2)
host
part
– Max Hosts/network : 16,777,216 - 2
11001000 00010111 00010000 00000000
(32 – x)-bit identifies
the specific hosts
24 bits of host address
First byte
‰CIDR: Classless InterDomain Routing (RFC 1519)
Network Layer
223.1.1.3
223.1.8.1
223.1.2.1
21
200.23.16.0/23
223.1.1.4
223.1.9.1
n A network consisting of 3 IP
networks (for IP addresses
starting with 223, first 24 bits
are network address)
network
Part: x-bit
223.1.1.2
223.1.1.1
call each a “network”
223.1.3.2
223.1.3.1
Network Layer
1
™ How to find the networks?
networks?
‰ Detach each interface from
routers and hosts
Æ create “islands” of
isolated networks
(224 – 1)
23
Network Layer
24
Classes of Original IP Address (cont’d)
Classes of Original IP Address (cont’d)
Class B
10
1414-bit network address
Class C
2121-bit network address
110
16 bits of host address
First two bytes
Last two bytes
8 bits of host address
First three bytes
Last byte
• Class B : 128.0.0.0 ~ 191.255.255.255
• Class C : 192.0.0.0 ~ 223.255.255.255
– Networks (Max) : 128.1.0.0 ~ 191.254.0.0 (16386 - 2)
– Networks (Max) : 192.0.1.0 ~ 223.255.254.0 (2097154 - 2)
– Max Hosts/network : 65,536 - 2
– Max Hosts /network : 256 - 2
• The most popular IP address assignment
• 20% of class B were assigned by July 1990 and DOUBLING
every 14 months Æ will be exhausted by Early 1994 (Not so bad)
Network Layer
(projection on March, 1994) Å May you find the up-to-date info ?
25
Network Layer
26
Classes of Original IP Address (cont’d)
Classful IP Addresses Summary
given notion of “network”, let’s re-examine IP addresses:
Class D
1110
Multicast address (group ID)
• Called “classful” addressing:
class
• Class D : 224.0.0.0 ~ 239.255.255.255 (Multicasting)
- mapped to a physical address (assigned in the NIC)
Class E
11110
Reserved for future use
A
0 network
B
10
C
110
D
1110
1.0.0.0 to
127.255.255.255
host
network
128.0.0.0 to
191.255.255.255
host
network
multicast address
host
192.0.0.0 to
223.255.255.255
224.0.0.0 to
239.255.255.255
32 bits
• Class E : 240.0.0.0 ~ 247.255.255.255 (Reserved)
Network Layer
27
Network Layer
28
Special IP Addresses
••
••
••
Private IP Addresses
Hostid
Hostid==all
all00ÖÖ
ÖÖ This
Thisnetwork
network
Netid
=
all
0
&
Hostid
=
Netid = all 0 & Hostid =any
any ÖÖ
ÖÖSpecified
Specifiedhost
hoston
onthis
thisNet
Net
Netid
Netid ==all
all00&
&Hostid
Hostid==all
all00ÖÖ
ÖÖThe
Thehost
hoston
onthis
thisNet
Net
(reusable)
• For local use only (allowing duplication among different LANs)
• A legal IP address only in a LAN (private use) but would not
•• Hostid
Hostid==all
all11ÖÖ
ÖÖBroadcast
Broadcaston
onthe
thespecified
specifiednetwork
network
(directed
broadcast,
getting
through
(directed broadcast, getting throughRouter)
Router)
be recognized by Internet (eg., routers)
• Three PIP’s range (RFC 1918) :
•• Netid
Netid ==all
all11&
&Hostid
Hostid==all
all11ÖÖ
ÖÖLAN
LANbroadcast
broadcastaddress
address
(limited
broadcast,
w/o
getting
through
a
Router)
(limited broadcast, w/o getting through a Router)
IP range
•• 127.x.x.x
127.x.x.xÖÖ
ÖÖloop
loopback
backaddress
address~~for
forinternal
internaltesting
testing
(packets
(packetswould
wouldnot
notbe
besent
sentonto
ontonetwork)
network)
**Mostly,
(Try: ping
ping127.0.0.1
127.0.0.1under
underMS-DOS
MS-DOSwindow)
window)
Mostly,use
use127.0.0.1
127.0.0.1 (Try:
** Those
ThoseSIPs
SIPsare
areapplicable
applicableto
tothe
thenetworks
networkswith
withsubnetting
subnetting
Network Layer
29
10.0.0.0 ~ 10.255.255.255
255.0.0.0
172.16.0.0 ~ 172.31.255.255
255.240.0.0
192.168.0.0 ~ 192.168.255.255
255.255.255.0
Network Layer
Note on PIP
30
IP Fragmentation and Reassembly
A Note on Private IP Address
‰ network links have MTU
(max.transfer size) - largest
possible link-level frame.
¾ different link types, different
MTUs
‰ large IP datagram divided
(“fragmented”) within net
¾ one datagram becomes
several datagrams
¾ “reassembled” only at final
destination
¾ IP header bits used to
identify, order related
fragments
‰ IPՏ֟ࢂԖज़‫ޑ‬ǴࣁΑှ،IP addressВᅌό‫ޑى‬ୢᚒǴ
RFC1918ύ‫ۓ‬ကΑ΋ࢤPrivate IP addressǴ೭ࢤIPёբࣁ
Ҿ཰‫ൂ܈‬ՏϣԾՉၮҔ‫ޑ‬IP AddressԶค໪࿶ၸ(ӛ΢ෞ)
ҙፎ‫ޑ‬ЋុǶ྽ฅ٬ҔൂՏѸ໪ॄೢόᡣ೭٤Private IP
Address‫ޑ‬Routing informationࢬ‫ൂډ‬ՏѦ‫ޑ‬ᆛၡ΢ǴΨ
൩ࢂ೭٤ႝတѝૈ‫ൂک‬Տϣ‫ޑ‬ႝတೱጕǴѦय़‫ޑ‬ᆛၡ࣮
ό‫ൂـ‬Տϣ೭٤Private IP Address‫ޑ‬ႝတǴӢԜ೭ࢤ
Private IP Addressёख़ᙟӦ೏όӕൂՏϣ೽‫܌‬٬ҔǴ຾
Զၲ‫ډ‬࿯࣪IP‫ޑ‬Ҟ‫ޑ‬Ƕӵ݀LANۘ҂ೱ΢Internetϐ߻Ǵ
ԾՉ೛‫ۓ‬LANϣ‫ঁޑ‬Γႝတ‫ޑ‬IPՏ࿼Ǵ೭٤IPՏ࿼όࢂ
࿶ၸҙፎਡ঑‫ޑ‬ӝ‫ݤ‬IPǴѝࢂӧLANύ٬Ҕ‫ޑ‬IPǴᙖа
୔ϩঁΓႝတ‫ޑ‬Տ࿼Ǵᆀࣁ‫د‬Γᆛၡ(private network) Ƕ
Network Layer
Mask
31
Network Layer
fragmentation:
in:
one large datagram
out:
3 smaller datagrams
reassembly
32
How Does IP Handle Fragmentations ?
VERS
HLEN Service Type
Identification
Identification
Identification
Time to Live
Fragmentation Control in the IP Header
Total Length
Flags
Flags
Protocol
• Identification — Contains an integer that identifies the current
datagram. The receiving IP layer use this field
and source IP address to help piece together
datagram fragments. (16-bit)
Fragment Offset
Fragment Offset
Header Checksum
• Flags — A 3-bit field of which the low-order 2 bits control
fragmentation. One bit specifies whether the packet
can be fragmented; the second bit specifies whether
the packet is the last fragment in a series of fragmented
packets.
• Different media allows for different-sized datagrams to be
transmitted and received.
• Fragmentation allows a datagram that is too large to be
forwarded to the next LAN segment to be broken up into
smaller segments to be reassembled at the destination.
• The fragmentation occurs at the router that cannot forward
packet to the next interface directly.
• Applications should use path MTU discovery (RFC 1191)
to find the smallest datagram size. Send 576 if no information.
Network Layer
• Fragmentation offset — Indicating the offset (in bytes) from the
previous datagram that continues the
complete datagram.
• Fragments’ header duplicate most of the original datagram header.
33
Network Layer
34
IP FAR (cont’d)
IP Fragmentation and Reassembly
•
‰Disadvantages:
DF: Don’t Fragment
0 ~ May Fragment
1 ~ Don't Fragment
- Larger buffers are required at intermediate gateways
- All fragments of a datagram may be forced to pass through
the same gateway. This inhibits the use of dynamic routing.
• Example
. . .
Ethernet 1
MTU = 1500
Fragment
Host B
Network
MTU = 500
Router
A
IN: 3980 data bytes;
IP header = 20 bytes
. . .
Ethernet 2
MTU = 1500
• IP reconstructing
~ by ψ total length ω
and ψoffset ω
Router
B
(Done by routers in today’s Internet)
35
0 1 2
0 DF MF
MF: More Fragments
0 ~ Last Fragment
1 ~ More Fragment
length ID fragflag offset
=4000 =x
=0
=0
MTU examples: FDDI ~ 4352; X.25 ~ 576; PPP ~ 296 bytes
Host A
Network Layer
Flag
Network Layer
One large datagram becomes
several smaller datagrams
length ID fragflag offset
=1500 =x
=1
=0
length ID fragflag offset
=1500 =x
=1
=1480
length ID fragflag offset
=1040 =x
=0
=2960
36
1
IP Routing - Getting a Datagram from Src to Dest
IP Addressing: the Last Word
(a preview)
Q: How does an ISP get block of addresses?
Misc. source dest
fields IP addr. IP addr.
¾ allocates addresses by three regional Internet registries
– handles registrations for North and South America, as well as
parts of Africa
• Reseaux IP Europeans (RIPE)
– covers Europe and nearby countries
• Asia Pacific Network Information Center (APNIC)
¾ manages DNS (root DNS servers)
¾ assigns domain names, resolves disputes
IP problems ?
data
37
Starting at A, given IP datagram
addressed to B:
• look up net. address of B first
A
• find B is on same network as A
– By consulting its IRT
• link layer will send datagram
B
directly to B inside link-layer
frame (discussed later)
Å B and A are directly/physical
connected
Network Layer
Here, 223.1.1 Æ 223.1.1.0/24
route directly
223.1.1.4
223.1.1.4
223.1.3.1
1
2
2
router 223.1.2.1
223.1.1.2
223.1.1.4
223.1.2.9
223.1.1.3
223.1.2.1
223.1.2.9
223.1.3.27
223.1.2.2
223.1.3.27
E
223.1.3.2
38
223.1.2.2
E
223.1.3.2
39
Network Layer
(next hop)
data
Starting at A, dest. E:
• look up network address of E
• E on different network (since
Nhop=2)
ÆA, E are not directly connected
• routing table Æ next hop router to
E is 223.1.1.4
• link layer sends datagram to router
223.1.1.4 inside link-layer frame
• datagram arrives at 223.1.1.4
(continued…..)
A Æ B
223.1.1.2
223.1.1.4
223.1.1.3
223.1.1.1
Network Layer
misc
fields 223.1.1.1 223.1.2.3
Dest. Net. next router Nhops
223.1.1.1
1
2
2
Forwarding a datagram – Scenario 2
Internal Routing Table in A
223.1.1
223.1.2
223.1.3
223.1.1.4
223.1.1.4
?
223.1.3.1
)reseau ~ ጻणิ៣*
?
223.1.1
223.1.2
223.1.3
Note: 223.1.1 Æ 223.1.1.0/24
Forwarding a datagram – Scenario 1
Misc.
fields 223.1.1.1 223.1.1.3
Dest. Net. next router Nhops
data
• datagram remains
unchanged, as it
travels along routers
A
(from source to
destination)
• address fields of
B
interest here
• American Registry for Internet Number (ARIN)
Network Layer
Internal Routing table in A
IP packet/datagram:
A: ICANN: Internet (Corporation for) Assigned Names and
Numbers (RFC 2050)
Dest. Net. next router Nhops
223.1.1
223.1.2
223.1.3
A
223.1.1.1
223.1.1.4
223.1.1.4
A Æ E
223.1.1.2
223.1.1.4
B
223.1.1.3
223.1.3.1
1
2
2
223.1.2.1
223.1.2.9
223.1.3.27
223.1.2.2
E
223.1.3.2
40
Forwarding a datagram – router
’s action
router’s
misc
fields 223.1.1.1 223.1.2.3
data
Arriving at 223.1.1.4, destined
for 223.1.2.2
• look up network address of E
• E on same network as
router’s interface 223.1.2.9
Ærouter, E directly attached
• link layer sends datagram to
223.1.2.2 inside link-layer
frame via interface 223.1.2.9
• datagram arrives at
223.1.2.2!!! (hooray!)
1 Router - the Internet Packet Forwarding Device
223.1.1
223.1.2
223.1.3
A
-
1
1
1
??
-
223.1.1.4
223.1.2.9
223.1.3.27
A Æ E
223.1.1.1
223.1.1.2
223.1.1.4
B
Packet
Frames Packet
223.1.2.1
223.1.2.2
E
223.1.3.27
223.1.1.3
223.1.3.2
223.1.3.1
41
mechanism
Packet
Out
Frames Packet
•
•
•
Routing is an overhead activity (store-and-forward)
Performance is derived from switching mechanism (forwarding rate in PPS)
Capability depends upon the protocols (e.g., IP, IPX) and interfaces (ports)
[e.g., E, FE, ATM(25,155.5,622.02 Mbps or more), T1/E1, T3] it can support
• Separate networks from broadcast and independent of OS and networks
42
Network Layer
Actions Taken by a Router upon Receiving a Packet
IP Packet Forwarding over Internet
What if the MAC address is unknown
Packet Received
NO
Header and
checksum valid?
In
Switch
223.1.2.9
Network Layer
1
List of Reachable
Networks
Dest.
next
network router Nhops interface
If route is available,
search for MAC
address in ARP
cache
NO
Received
ARP
Reply?
YES
Host - 129.1.1.2
Host - 129.1.1.1
D
E
DA SA TF
Data
CRC
YES
Decrement TTL;
TTL >= 0?
NO
Send ICMP
error message
to originator
YES
Discard original
packet
NO
YES
Network Layer
Send ARP request
and wait for a
response
129.1.1.3 C
NO
Build new packet with
MAC address and
route packet through
port found in routing
table.
IP Header
Router
YES
Route Table lookup
based on
destination address
Route
found?
NO
MAC address
found?
129.2.1.1
Received ARP reply,
insert MAC and IP
address into
ARP table
Default route
available?
129.2.1.2
A
YES
43
Network Layer
B
D C 0800 129.2.1.2 129.1.1.2 IP Data CRC
IP Header
B A 0800 129.2.1.2 129.1.1.2
IP Data CRC
44
Some a prior information are needed
before sending out a Packet
Address
Address Resolution
Resolution Protocol
Protocol (ARP)
(ARP)
Oops"!ჹόଆٰ"
• RFC 826.
• TCP/IP addresses are 32 bits and represent a
network, subnet, and host ID.
• Addresses on LANs are represented by physical
(MAC) layer addresses and they are 48 bits in length.
• ARP provides the mapping between a host’s 32-bit IP
address and its 48-bit MAC address.
• ARP works only on the local subnet (it cannot traverse
routers).
• ARP builds a table of IP/MAC addresses to properly
format a source and destination address field in a
packet (ARP cache).
• What if the MAC address of a destination is
unknown giving IP address ?
Î Calls for ARP to find it out
• What if the IP address is unknown giving host name
only?
Î Calls for DNS lookup
45
Network Layer
46
Network Layer
ARP Operations : Request and Reply
ARP Packet Format
~ IP address (4-byte) Ö MAC address (6-byte) service
Type of hardware address
Type of protocol address
• ARP request (via broadcasting) :
Length of header
A asks MAC address of B (with IP address given) = ?
Operation
A
router
Length of protocol address
Hardware address of the source station
Protocol address of the source station
An LAN segment
Hardware address of the destination station
B
Protocol address of the destination station
(ARP ignored)
• ARP reply :
DA SA
B (only) replies its MAC address; others keep silent
TF
Data
CRC
A
router
Network Layer
B
(ARP over Ethernet directly)
An LAN segment
HA type = 1 (for Ethernet) ; PA type = 0x0800 (w/ IP)
Operation = 1 (request) or 2 (response)
47
Network Layer
48
ARP : Local and Remote
ARP : Sending, Identifying, and Caching
• Router replies its MAC address if B is located out of the segment
• Transmit ARP in a frame
ARP broadcast packet
~ Get local destination’s
MAC address
local
To find B’s Subnet mask
MAC addr
remote ARP broadcast packet
~ Get router’s MAC address
• Identifying ARP frame
• To see the ARP cache (maintained by the station for a short period)
- arp –a (empty, when you just open it)
- arp –a (check arp cache after a few connections)
• ARP software maintains a small table of bindings
(IP Ù MAC address) in memory – called ARP cache
~ to reduce network traffic (but not last for too long)
• RARP (Reverse ARP) ~ In contrast to ARP
~ MAC address Ö IP address mapping services
~ For diskless devices (a way of managing IP address)
49
Network Layer
50
Network Layer
DNS Naming Rule
Domain Name Service (DNS)
Example: Naming hierarchy in internet
• Domain (ᆛୱ) ~ the coverage of a Netid (network)
• DNS ~ Hierarchical (໘ቫԄ) naming rules in internet
– Example: Host name -- en.ntut.edu.tw, www.edu.tw
www.epson.com.tw
• Domain Name System Server (DNS server)
~ containing a database (look-up table) for host name to
IP address mapping
– Example: Host name
en.ntut.edu.tw
root* (use country/area, tw)
sun.cc.ntut.edu.tw
forming
order
com
edu
gov
nctu
ntut
ntu
cc
sun
IP address = 140.124.70.26
en
ftp
(Ultra 5)
Top-level domains
second-level domains
Host name:
en.ntut.edu.tw
(Enterprise 3000)
* Note: root is generally unnamed
Network Layer
51
Network Layer
52
Name Resolving Operation
DNS (cont’d)
• Links among DNS servers
Example: (iterative resolution - one of query methods)
- All DNS servers are linked together to form a unified system
A remote site (say, syl.ntu.edu.tw) sends a request to its local DNS server
- Each server knows how to reach a root server and servers that
are authorized by itself (the further down the hierarchy)
‘ntu.edu.tw’ for resolving the name “ kwk.en.ntut.edu.tw ”
3. Reply ntut.edu.tw’s IP
root server
8
tw
edu.tw - 140.111.1.2
Question: How does a DNS server know which other DNS
server is the authority for a given name ?
Answer: It does not know. Gee!
2
ncu
??
cc
- The DNS server know where is the root DNS server
and resolve the name from there
5
6
en
syl.ntu.edu.tw
1
7
5. Reply en.ntut.edu.tw’s IP
7. Reply kwk.en.ntut.edu.tw’s IP
sun
- the resolver acts as a client by sending DNS request to
other DNS servers for name resolving (call for help)
server for
ntut.edu.tw
53
URL (Uniform Resource Locator)
1
ntu
4
ntut
• Resolving a name (machine)
Network Layer
Ftp kwk.en.ntut.edu.tw
edu
Network Layer
1
ftp
kwk
wkc
The authority server of
“ x.en.ntut.edu.tw ”
54
URL Examples
• URL (ᆛ֟)
~ providing a uniform way to access resources in the Web
• Format
–– “protocol”://
“protocol”:// “host
“host name”
name” “port”
“port” “path”
“path”
–– Examples:
Examples:
1. http://www.news.edu.tw :8080 /path/file/index.html
=/or server’s IP address port # (default
(default == 80
80 for
for http
http
server)
server)
* Server’s address: www .news. edu. tw
(machine name)
Domain
1. Gopher://mitdir.mit.edu:105
9 2. Mailto:[email protected]
9 3. News:com.dcom.cell-relay
2. file:///C:/ProgramFiles/Netscape/kwk/bookmark.htm
Network Layer
55
Network Layer
56
Summary of IP Transfer over Internet
1
1
C
Hosts (host portion):
Router
Token
Ring
A
Router
Internet
B
• Case 1: A Ù B ~ direct (no router involved)
• Case 2: A Ù C ~ indirect (via default router first)
Dest & Src MAC addr altered hop-by-hop,
but IP addresses keep unchanged through.
o
(via ARP if any)
Destination
MAC addr
Network Layer
Source
MAC addr
Ethernet Header
Be referring to
subnet/net mask
all the time
n
IP header:
SRC IP
DEST IP
~ ࡐࡳIP
• Manual configuration:
– hard-coded by system administrator into the host (in a file)
• DHCP: Dynamic Host Configuration Protocol: (RFC 2131)
(dynamically get address: “plug-and-play”)
~ ۞೯࠷൓
™DHCP Protocol’s Four-step process:
– 1. “DHCP server discovery”
– 2. “DHC server offer(s)”
– 3. “DHCP request”
– 4. “DHCP ack”
Example
(via DNS if any)
Type
0800H
IP Addresses: How to get one?
IP data
area CRC
IP packet
ƒ DHCP is an extension of BOOTP (RFC1542) and is used
extensively in LANs and in residential Internet access.
57
1
Immediate IPv4 Problems
(explained later)
Network Layer
58
Subnetting – Dividing the Network Locally
• What is a Subnet )ηᆛၡ*!?
~ A network segment (with different network ID in their
IP address) separated by routers.
)ጻ੄*
• Running out of network ID’s . . .
• Solution:
Subnetworking (subnetting)
Class B
Customer Site
Invisible to Internet
130.1.0.0
130.1.0.0
• Running out of IP addresses . . .
• Solutions:
DHCP
NAT
CIDR
Internet
130.1.1
130.1.1.0
130.1.2
130.1.2.0
130.1.3
130.1.3.0
.......
130.1.255
.0
130.1.255.0
• Why need a subnet ?
~ to create more networks ID (by reducing host ID)
~ to help conserve the IP address space
Network Layer
59
Network Layer
60
Subnetting by Subnet Mask
1
Defining a Subnet Mask
1
• How to do it ?
~ One network assigned to a site and it is allowed to
“chop” up that network number to create subnets.
3
5
Original
Host field
~ by “subnet mask” that divides the IP address into subnets
(RFC 950)
128
128 64
64 32
32 16
16 88 44 22 11
• Example – Define a subnet mask
1 1 1 1111 1
Ö Subnet mask = 255.255.255.224
Net ID
Host ID
Static subnetting
61
Network Layer
Subnetting Example
1
Network Layer
A Class C IP address = 203.54.48.0 ~ 256 nodes max.
Wanted: Subnetting it to FOUR subnets .
Require to set Subnet Mask = 255.255.255. xxx
ÖÖ 11111111.11111111.11111111.xxxxxxxx
no of subnets d 2 n
• The resulting subnet IP addresses:
– This leaves 9 bits for host assignment (16 - 7) which allows
for 510 hosts
• Subnets are masked starting from the left and hosts are configured
starting from the right.
with respect to “old Host ID field”
Result:
IP address for subnet #1 = 203.54.48.
~ 203.54.48. x
IP address for subnet #2 = 203.54.48.
~ 203.54.48. x
IP address for subnet #3 = 203.54.48.
~ 203.54.48. x
IP address for subnet #4 = 203.54.48.
~ 203.54.48. x
150 . 5 . X X X X X X X X . X X X X X X X X
Subnet Mask
255.255.254.0
Network Layer
62
Subnetting Exercise
1
• IP address assignment 150.5.0.0.
• Requirements of 75 subnets and 75 hosts per subnet.
• First set is to find out how many bits are needed for 75 subnets ?
– 25 = 32, 26 = 64 and 27 = 128 > 75 therefore we need
n = 7 bits to subnet for 75 subnets
128
128
192
192
224
224
240
240
248
248
252
252
254
254
255
255
• What is the broadcast addresses for each subnet ?
Host Address
63
Network Layer
Static subnet
Cont’d . . . on IP Routing
64
DHCP Client-Server Scenario
DHCP:
DHCP: Dynamic
Dynamic Host
Host Configuration
Configuration Protocol
Protocol
223.1.2.5
* Obtaining a host address automatically, Method - I:
A
Goal:
- Allow host to dynamically obtain its IP address from network
223.1.1.4
223.1.1.3
65
arriving
client
* Obtaining a host address automatically, Method - II:
rest of
Internet
DHCP offer
src: 223.1.2.5, 67
dest: 255.255.255.255, 68
Your inet addr: 223.1.2.4
transaction ID: 654
Lifetime: 3600 secs
src: 0.0.0.0, 68
dest:: 255.255.255.255, 67
Your inet addr: 223.1.2.4
transaction ID: 655
Lifetime: 3600 secs
Local/private network
(e.g., home network)
10.0.0/24
10.0.0.4
NAT-enabled
Echo back
src: 223.1.2.5, 67
dest: 255.255.255.255, 68
Your inet addr: 223.1.2.4
transaction ID: 655
Lifetime: 3600 secs
10.0.0.1
10.0.0.2
138.76.29.7
All datagrams leaving local
network have same single source
NAT IP address: 138.76.29.7,
different source port numbers
DHCP ACK
(yiaddr – addr allocated to the new client)
66
NAT:
NAT: Network
Network Address
Address Translation
Translation
src : 0.0.0.0, 68 (Å BOOTP client port)
dest.: 255.255.255.255,67 (server port)
Your inet addr: 0.0.0.0
transaction ID: 654
time
223.1.3.2
arriving DHCP
client needs
address in this
network
Network Layer
DHCP client
-server scenario (explained)
client-server
DHCP request
223.1.2.2 E
Double click
Network Layer
(if choosing)
223.1.3.27
223.1.3.1
DHCP discover
223.1.2.9
B
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
DHCP server: 223.1.2.5
May I have an IP address?
223.1.1.2
• DHCP operations:
Network Layer
223.1.1.1
server
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)
–
–
–
–
223.1.2.1
DHCP
renew
67
Network Layer
10.0.0.3
Datagrams with source or
destination in this network
have 10.0.0/24 address for
source, destination (as usual)
68
NAT (cont
’d)
(cont’d)
NAT (cont
’d)
(cont’d)
• Implementation: NAT router must (do for)
• Motivation: local/private network uses just one IP address as
far as outside word is concerned:
– outgoing datagrams: replace (source IP address, port #) of
every outgoing datagram to (NAT IP address, new port #)
– no need to be allocated range of addresses from ISP: - just
one (or more ?) IP address is used for all devices
. . . remote clients/servers will respond using (NAT IP address, new
port #) as destination addr.
– can change addresses of devices in local network without
notifying outside world (but this violates ene-to-end argument in
– remember (in NAT translation table) every (source IP
address, port #) to (NAT IP address, new port #) translation
pair
Internet)
– can change ISP without changing addresses of devices in
local network
– incoming datagrams: replace (NAT IP address, new port #)
in dest fields of every incoming datagram with
corresponding (source IP address, port #) stored in NAT
table
– devices inside local net are not explicitly addressable and
visible by outside world (a security plus).
69
Network Layer
NAT (cont
’d)
(cont’d)
NAT Example
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
S: 10.0.0.1, 3345
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
Network Layer
3
• 16-bit port-number field:
1: host 10.0.0.1
sends datagram to
128.119.40, 80
138.76.29.7, 5001 10.0.0.1, 3345
……
……
S: 138.76.29.7, 5001
D: 128.119.40.186, 80
70
Network Layer
1
10.0.0.4
S: 128.119.40.186, 80
D: 10.0.0.1, 3345
– 60,000 simultaneous connections with a single LANside address!
• NAT is controversial:
– routers should only process up to layer 3
– violates end-to-end argument
10.0.0.1
• NAT possibility must be taken into account by app designers,
eg, P2P applications
10.0.0.2
4
– address shortage should instead be solved by IPv6
– NAT is a stopgap solution ÅIpv6 enthusiastic person’s
complaint(៾‫ە‬ϐी)
10.0.0.3
4: NAT router
changes datagram
dest addr from
138.76.29.7, 5001 to 10.0.0.1, 3345
71
Network Layer
72
What
’s Wrong with the IP Addressing ?
What’s
Problem with Class C IP Address Assignment
• 32-bit IP address
~ Allows for 4,294,967,296 unique addresses
- Addresses are grouped in a class (group), most of which
are wasted .
• Subnetting (RFC 950) – provides better address space
granularity within each network
Ö Solves problem - “running out of class B Address”
• However, it introduces another problem . . .
• Addresses were arbitrarily handed out without regard to
geographic location :
(May, 1996)
~ more than 50 percent of the businesses were small
- Class A stopped being handed out (running out).
- Class B was near depletion (ex., 3000 out-of-65534 left)
- Class C addresses were overtaxing the Internet routing
tables.
Î Every class C address requires a routing table entry
and medium-sized. Class C addresses were needed.
Î Internet routing tables explosion
• How to prevent this ?
• RFC 1338 introduced supernetting for fixing.
Solution Æ Using “Classless Inter-Domain Routing”
73
Network Layer
74
Network Layer
Classless InterDomain Routing : A
ISP
’s Partition of IP addresses
ISP’s
1
Flexible and Efficient IP Address Assignments
• Variable Length Subnet Masks (VLSM)
~ placing a variable-length subnet mask on a single IP
Network (network portion):
• get allocated portion of ISP’s address space:
ISP allocated the block and
give those smaller blocks out
network number. -- the first thought
• Terminology:
Subnetting Æ … longer than …
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
- Supernetting ~ applying a mask to an IP address that is
shorter than its natural (default) mask.
- Address aggregation ~ summarizing contiguous blocks of
(Route)
IP networks as one advertisement.
• Classless Inter-Domain Routing (CIDR)
~ An advertisement mechanism that allows for advertising
routes without regard to Class assignment. The route could
be identified by a supernet or by an extended subnet mask.
Network Layer
(divide into 8 blocks)
75
Network Layer
* CIDR facilitates hierarchical routing
76
1
1
Hierarchical addressing: route aggregation
(route summarization)
• ISP-B has a more specific route to Organization 1
• Hierarchical addressing allows efficient advertisement
of routing information – use a single network prefix to
advertise multiple networks Æ route aggregation
Organization 0
200.23.16.0/23
Organization 1
200.23.18.0/23
Organization 2
200.23.20.0/23
.
.
.
Organization 7
200.23.30.0/23
Organization 0
200.23.16.0/23
Advertises to outside world . . .
.
.
.
ISP - A
Organization 2
200.23.20.0/23 ..
.
.
. 7
Organization
.
200.23.30.0/23
“Send me anything
with addresses
beginning
200.23.16.0/20”
“Send me anything
with addresses
beginning 199.31.0.0/16”
ISP - A
Internet
ISP - B
Internet
“Send me anything
with addresses
beginning 199.31.0.0/16
or 200.23.18.0/23”
Organization 1
200.23.18.0/23
Renumbering IP? No!
(moved but keep the IP address unchanged)
77
Router’s operation
78
Network Layer
ICMP Packet Format
Internet
Internet Control
Control Message
Message Protocol
Protocol (ICMP)
(ICMP)
0
8
15
31
IP Header (20 bytes)
• The internetworking facility does not guarantee successful
delivery of every datagram
Type
ICMP
message
• Datagram may be discarded for a number of reasons :
– lifetime expiration (in TTL field)
– congestion (in Network)
– bit error (being detected)
Code
Checksum
Parameters
64-bit ICMP
header
Contents depends on type and code
• Type ~ specify the ICMP message is a query or an error
(e.g., type = 3, 4, 5, 11, 12)
• Code ~ distinct type of error or query
Ex: type & code = 3 & 3 Ö port unreachable
9 • Internet flow control allows gateways or receiving stations, or
both, to limit the rate at which they receive data.
• The best approach would seem to be to send flow control
packets. This can be done using the ICMP protocol (RFC 792)
9 • ICMP provides feedback about problems in the communication
environment that require attention.
Network Layer
“Send me anything
with addresses
beginning
200.23.16.0/20”
200.23.18.0/23
The rest of the world need not know that
within the address block 200.23.16.0/20
there are 8 other organizations/networks.
ISP - B
Network Layer
Longest Prefix Matching
Matching:: more specific routes
( more specific address prefix)
• Checksum ~ covers the entire ICMP message (required)
• An ICMP error message is never generated in response to an
ICMP error message.
79
Network Layer
80
ICMP Message Formats
ICMP Message Types – Currently Used
• Destination Unreachable (network, host, protocol, port)
• Time Exceeded (TTL = 0 during transit, in Traceroute)
• Parameter Problem (bad IP header, e.g., improper options)
• Source Quench (elementary Flow control, reduce the
transmission rate of sending-end)
• Redirect (Migrate to a better path for network or host)
• Echo Request Testing the communication path,
• Echo Reply
e.g., used in ping program
• Timestamp Request (Sampling the delay characteristics
of the internet)
• Timestamp Reply
81
Network Layer
ICMP message Transport
Protocol Number (type) in IP Packet
0 Reserved
1 Internet Control Message Protocol (ICMP)
2 Internet Group Management Protocol (IGMP)
3 Gateway-to-Gateway Protocol (GGP)
4 IP (IP encapsulation)
5 Stream
6 Transmission Control Protocol (TCP)
8 Exterior Gateway Protocol (EGP)
9 Private Interior Routing Protocol
17 User Datagram Protocol (UDP)
41 IP Version 6 (IPv6)
50 Encap Security Payload for IPv6 (ESP)
51 Authentication Header for IPv6 (AH)
89 Open Shortest Path First
Reference: Internet STD 2 — Assigned Internet Numbers.
• Error messages go back to original source (may cross internet)
• Message carried in IP (specified by IP type)
• Although ICMP is at the same level as IP (a part of the IP
layer), it is a user of IP.
• No error messages about ICMP error messages
Network Layer
82
Network Layer
83
Network Layer
(or RFC 1700)
84
Example – Echo Request/Reply
192.1.1.1
Ping - P
acket IN
ternet G
roper
Packet
INternet
Groper
- Ping uses the ICMP Echo and Echo Reply messages
192.1.1.2
router
to determine whether a host is reachable.
• ping loopback-address* (Ex: 127.0.0.1)
Echo Reply
~ verifies the operation of NIC and base TCP/IP software
• ping a-Host’s-IP-address (self & a subnet neighbor)
192.1.2.2
~ verifies whether the physical network device can be
Echo Request 192.1.2.1
addressed. (still be ok even without a router/gateway)
• ping gateway’s-IP-address
~ verifies whether the gateway (your LAN’s router) works
192.1.1.2
• Sender: record the txing time in ICMP data field and subtract it from
the current time when receiving the returned ICMP packet
• Used in “ping” or “TCP delay estimation”
85
Network Layer
• ping a-remote-host-name (or DNS server’s IP directly)
~ verifies the operation of the name server
Routing
Routing Principle
Principle
Routing protocol
Goal: determine “good” path
(sequence of routers) thru
network from source to
DEST.
Ex:
Routing Algorithm Classifications
5
2
A
B
2
1
D
3
C
3
1
5
F
1
E
2
17 paths possible!
‰ “Good” path:
‰ Graph abstraction for routing
¾ typically means minimum
algorithms:
cost path
¾ graph nodes are routers
¾ Cost Æ hops/links/delay
F
• link cost: delay, $ cost, or
¾ graph edges are physical
congestion level
links
(other definitions are possible)
Network Layer
86
Network Layer
87
™ Global or decentralized
—
information?
Global:
¾ All routers have complete
topology (connectivity) and
link cost info
¾ Known as link state algorithms
Decentralized:
¾ Router only knows physicallyconnected neighbors and link
costs to neighbors
¾ Iterative process of computation,
exchange of info with neighbors
¾ Known as distance vector
algorithm
Network Layer
™ Static or dynamic?
Static:
¾ Routes (routing
information) change
slowly over time
Dynamic:
Dynamic —
¾ Routes change more
quickly
• periodic update, or
• in response to link
cost changes
88
Dijsktra’s
Dijsktra’s Algorithm
Algorithm
A Link-State Routing Algorithm
™ Dijkstra’s algorithm
‰ Net topology and link costs are
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 (candidate destinations)
¾ gives routing table for that
node
‰ Iterative: after k iterations, know
least cost path to k destinations
Notation:
‰ c(i,j): link cost from node i to j.
c(i,j) = infinite, if not direct
neighbors (directly connected)
‰ D(v): current value of cost of
path from source to dest. V
‰ p(v): predecessor node along
path from source to v, that is
next v
12
‰ N: set of nodes whose least
cost path definitively known
Network Layer
89
5
2
A
B
2
1
Network Layer
D
3
C
3
1
5
F
1
E
2
V = {A, B, C, D, E, F}
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 */
Network Layer 15 until all nodes in N
90
Dijkstra’s Algorithm’s Complexity
D(B),p(B) D(C),p(C) D(D),p(D) D(E),p(E) D(F),p(F)
1, A
2, A
5, A
infinity
infinity
2, A
4, D
2, D
infinity
2, A
3, E
4, E
3, E
4, E
4, E
start N
A
AD
ADE
ADEB
ADEBC
ADEBCF
D(v) = min( D(v), D(w) + c(w,v) )
FYI
Dijkstra’s Algorithm - Example
Step
0
1
2
3
4
5
1 Initialization (step 0):
2 N = {A}
3 for all nodes v
4
if v adjacent to A /* directly attached */
5
then D(v) = c(A,v)
6
else D(v) = infinity
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:
‰ Algorithm complexity: suppose n nodes (excluding the
source node)
¾each iteration: need to check all nodes, w, not in N
¾Need n(n+1)/2 comparisons: O(n**2)
• For each node, we got its predecessor
along the least-cost path from the src,
and so forth for each predecessor.
• Then the source node constructs its
next-hop node to the given destination.
91
‰ Calls for more efficient implementations Æ O(n·logn) (A
more sophisticated implementation of this algorithm,
using a data structure known as a heap, can find the
minimum in line 9 in logarithmic rather than linear time,
thus reducing the complexity.
Network Layer
92
Dijkstra’s Algorithm’s Instability
Distance Vector Routing Algorithm
‰ Oscillations for asymmetry links
™ DV is . . .
¾ distributed:
each node communicates
only with directly-attached
neighbors
¾ Iterative:
continues until no info
exchanged between
neighbors (self-terminating:
no “signal” to stop)
¾ asynchronous:
nodes need not exchange
info/iterate in lock step w/
each other
¾Ex: link cost { amount of carried traffic (e.g., delay)
(a) Initial routing
A
1
D
0
1
DÆA
(c) B,C,D detect better
path to A, CCW
1+e
D
B
0 0
e
C
1
1 traffic
originated
BÆA
e
CÆA
A
0
A
2+e
(b) B, C deteect
D
better path
to A, CW
1
0
1+e 1
C
2+e
0 0
1
C
B
1+e
1
e
(d) B,C,D detect better
path to A, CW
0
D
B
0
1
1
A
2+e
0
B
1+e 1
e
C
e
Network Layer
0
1
e
93
Network Layer
7
A
1
E
X
2
distance from X to
D (Y,Z) = Y, via Z as next hop
2
8
1
Distance:
C
E
D
D
D (A,D) = c(E,D) + minw {D (A,w)}
Loop back!
B
D (A,B) = c(E,B) + min {D (A,w)}
w
Network Layer
= 8+6 = 14 Loop back!
destination
B
D
A
1
14
5
A
A,1
B
D
B
7
8
5
B
D,5
A
1
14
5
C
6
9
4
C
D,4
B
7
8
5
D
4
11
2
D
D,2
C
6
9
4
D
4
11
2
destination
= 2+2 = 4
E
A
D
D (C,D) = c(E,D) + minw {D (C,w)}
= 2+3 = 5
Outgoing link
to use, cost
A
Z
cost to destination via
E
cost to destination via
D ()
= c(X,Z) + minw{D (Y,w)}
D.T. for E DE ()
E
94
Routing Table – from Distance Table
Distance Table: an Example
B
™ Distance Table data
structure
¾ each node has its own
table
¾ one row for each
possible destination
¾ column for each directlyattached neighbor to
node
¾ example: in node X, for
dest. Y via neighbor Z:
Distance table
95
Network Layer
destination
FYI
Routing table
96
Distance Vector Routing: Overview
‰ Iterative, asynchronous: each
local iteration caused by:
¾ local link cost change
¾ message from neighbor: its
least cost path change from
neighbor
‰ Distributed:
¾ each node notifies
neighbors only when its
least cost path to any
destination changes
¾ neighbors then notify their
neighbors if necessary
Bellman-Ford Algorithm
Each node:
At all nodes, X:
1 Initialization:
2 for all adjacent nodes v:
X
3 D (*,v) = infinity
/* the “ * ” operator means "for all rows" */
X
4 D (v,v) = c(X,v)
wait for (change in local
link cost of msg from
neighbor)
recompute distance table
5 for all destinations, y
X
6 send min D (y,w) to each neighbor
W
/* w over all X's neighbors */
7
if least cost path to any
dest has changed, notify
neighbors
Network Layer
97
Network Layer
BellmanBellman-Ford Algorithm (cont.)
Distance Vector Algorithm: an Example
(at each node X)
8 loop
9 wait (until it sees a link cost change to neighbor V
10
or until it receives an update from neighbor V)
11
12 if ( c(X,V) changes by an amount of d)
13 /* change cost to all dest's via neighbor v by d */
14 /* note: d could be positive or negative */
X
X
Å recomp.
15
for all destinations y: D (y,V) = D (y,V) + d
16
17 else if ( update received from V w.r.t. destination Y)
18 /* shortest path from V to some Y has changed */
v
19 /* V has sent a new value for its minw D (Y,w) */
20
/* call this received new value is "newval"
*/
X
98
X
2
Y
7
1
Z
¹ recomp.
21 for the single destination y: D (Y,V) = c(X,V) + newval
22
X
23 if we have a new min D (Y,w) for any destination Y
w
Network Layer
X
24
send new value of min D (Y,w) to all neighbors
w
25 forever
99
Network Layer
~ current minimum path cost to a destination
~ a new minimum cost has been computed
100
Comparison of LS and DV algorithms
Distance Vector Algorithm: example
• update received from V w.r.t. destination Y
need to be recomputed
(B-F algorithm line 21)
X
2
Y
7
1
Triggered by Z:
Z
Z
X
D (Y,Z) = c(X,Z) + minw{D (Y,w)}
= 7+1 = 8
newval
Triggered by Y:
Y
X
D (Z,Y) = c(X,Y) + minw {D (Z,w)}
1. Message complexity
‰ LS: with n nodes, E links,
O(nE) msgs sent each
‰ DV: exchange between
neighbors only
¾ convergence time varies
3. Speed of Convergence
‰ LS: O(n**2) algorithm
requires O(nE) msgs
¾ may have oscillations
‰ DV: convergence time varies
¾ may be routing loops
¾ count-to-infinity problem
= 2+1 = 3
Network Layer
101
Network Layer
Realistic Routing Issues in Internet
Network Layer
102
Hierarchical Routing
™ Our routing study thus far - idealization
¾ all routers identical
¾ Network structure is “flat”
… Noooooo! It is not true in practice.
™ scale:
scale
with more than 50 million
destinations and routers:
¾ can’t store all dest’s in routing
tables!
¾ routing table exchange by LS
or DV would swamp links Æ
No more BW left for sending
data packets
2. Robustness:
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 thru
network indirectly
™ administrative autonomy:
autonomy:
¾ internet = network of
networks
¾ each network administrator
may want to control routing
in its own network
‰ Solution: aggregate routers
into regions Æ “autonomous
systems” (AS)
‰ Routers in same AS run
same routing protocol (DV
or LS)
¾ “intra-AS” routing
protocol
‰ Routers in different ASs can
run different intra-AS
routing protocols via
gateway routers
(Idea: next page)
103
Network Layer
gateway routers
‰ Special routers in AS
¾ Run intra-AS
routing protocol
with all other routers
in AS
‰ Also responsible for
routing to destinations
outside AS
¾ run inter-AS routing
protocol with other
gateway routers
104
Routing in the Today’s Internet
Hierarchical - Intra-AS and Inter-AS RP
C.b
a
Host h1
C
A.a
b
Inter-AS
routing
between
A and B
A.c
d
A
a
b
Gateway
‰ The Global Internet consists of Autonomous Systems (AS)
interconnected with each other:
B.a
a
c
B
c
Intra-AS routing
within AS A
¾ AS: comprised of multiple networks/routers sharing all
routing information under a single administration (i.e.,
routing protocol)
¾ Stub AS: small corporation: one connection to other AS’s
¾ Multihomed AS: large corporation (no transit) with
multiple connections to other AS’s
¾ Transit AS: service provider, hooking many AS’s together
Host h2
b
Intra-AS routing
within AS B
‰ Two-level routing:
¾ Intra-AS: administrator responsible for choice of routing
algorithm within network ~ RIP, OSPF
¾ Inter-AS: unique standard for inter-AS routing ~ BGP
inter-AS, intra-AS
routing in gateway A.c
Network Layer
105
Network Layer
106
RIP
RIP (( Routing
Routing Information
Information Protocol)
Protocol)
Intra-AS Routing
‰ Adopted by Xerox Network System architecture firstly
‰ Also known as Interior Gateway Protocols (IGP)
‰ Most common Intra-AS routing protocols:
‰ Included in BSD-UNIX Distribution in 1982
‰ Use Distance vector algorithm
¾ RIP: Routing Information Protocol
¾ Distance/cost metric: # of hops (max = 15 hops)
¾ OSPF: Open Shortest Path First
¾ Can you guess why?
‰ Distance vectors: exchanged every 30 sec via Response
Message (called RIP advertisement) with neighboring routers
¾ IGRP: Interior Gateway Routing Protocol (Cisco
proprietary)
¾ Each advertisement contains up to 25 destination networks
‰ RIPv1~ RFC 1058; RIPv2 ~ RFC 2453 (allows route aggregation)
‰ For classful addressing, no VLSM supporting
Network Layer
107
Network Layer
108
RIP Version 2 – Packet Format
How does the RIP Advertisement Work ?
(a portion of an AS)
Command
Version
Unused
Route Tag
Address Family Identifier
Net 1 address
Subnet mask (v2 only)
NextNext-Hop IP Address
Metric
Route Tag
Address Family Identifier
Net 2 address
Subnet mask
Next Hop
Metric
DA SA
TF
IP Hdr UDP Hdr
UDP Data
z
w
x
D
y
B
…
C
Routing table in D
Destination Network
w
y
z
x
CRC
(use multicast instead of broadcasting in RIP v1)
Network Layer
A
109
….
Next Router
Num. of hops to dest.
….
....
A
B
B
--
2
2
7
1
Network Layer
How does the RIP Advertisement Work ?
110
RIP: Link Failure and Recovery
Advertisement sent from router A
Destination Network
z
w
x
….
Next Router
C
---
Num. of hops to dest.
‰ If no advertisement heard after 180 sec (missing 6 updates)
Route-timeout timer
4
1
1
….
¾ routes via neighbor invalidated (no longer reachable)
¾ new advertisements sent to neighbors
....
¾ neighbors in turn send out new advertisements (if tables
changed)
• Routing table in D updated to (after rerunning DV algorithm) …
Routing table in D
Destination Network
w
y
z
….
Network Layer
Next Router
A
B
A
….
¾ link failure info quickly propagates to entire net
Num. of hops to dest.
‰ Route-flush timer: removed a route from routing table after being
2
2
5
declared invalid for 240 sec.
‰ Poison reverse used to prevent ping-pong loops
(infinite distance = 16 hops)
....
111
Network Layer
112
RIP Table processing
RIP Table example (continued)
‰ RIP routing tables managed by application-level process
called “routed (route dee) ” (daemon) – executes RIP protocol
Router: giroflee.eurocom.fr
Destination
-------------------127.0.0.1
192.168.2.5
193.55.114.6
192.168.3.5
224.0.0.0
default (0.0.0.0)
‰ Advertisements sent in UDP packets, periodically repeated
‰ Use “netstat –rn” to view routing table
‰
‰
‰
‰
‰
Network Layer
113
Use
Interface
------ --------26492
lo0
13
fa0
58503
le0
25
qaa0
0
le0
143454
Three attached class C networks (LANs)
Router only knows routes to attached LANs
Default router used to “go up”
Route multicast address: 224.0.0.0
Loopback interface (for debugging)
Network Layer
114
OSPF’s “Advanced” Features (not in RIP)
OSPF (Open
(Open Shortest
Shortest Path
Path First)
First)
OSPF
‰ “Open”Æ publicly available Å opposed to Cisco’s EIGRP
‰ RFC 2178, 2328
‰ Uses Link State algorithm (LS – the topology of the AS) with
¾ LS packet dissemination
¾ Topology map at each node
¾ Route computation using Dijkstra’s lease-cost algorithm
‰ Security: all OSPF messages authenticated (to prevent
malicious intrusion – injecting incorrect info into routing
tables)
‰ 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:
‰ 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
‰ Supports VLSM and CIDR
Network Layer
Gateway
Flags Ref
-------------------- ----- ----127.0.0.1
UH
0
192.168.2.5
U
2
193.55.114.6
U
3
192.168.3.5
U
2
193.55.114.6
U
3
193.55.114.129
UG
0
¾ Multicast OSPF (MOSPF) uses same topology database as
OSPF
‰ OSPF allows to structure an AS hierarchically within a large
domains (to ease routing)
115
Network Layer
116
Generic Packet Formula
Metrics (cost)
Version
• Cost = a configurable parameter with the output side of
each router interface
• Reference RFC 1253 (OSPF v.2 MIB)
• Metric = 108 / interface speed (recommended)
Network Layer
• Examples:
– 100 Mbps
– 10 Mbps
– E1 (2.048 Mbps)
– T1 (1.544 Mbps)
– 64 kbps
– 19.2 kbps
– 9.6 kbps
Packet Length
Router ID
Area ID
Checksum
Authentication Type
Authentication
LSA Specific
1 – Hello, 2 – DB Description, 3 – LS Request,
4 – LS Update, 5 – LS Ack
1
10
48
65
1562
5208
10416
DA SA
117
TF
IP Header
Protocol ID 89
IP Data
CRC
Network Layer
118
Hierarchical OSPF (cont’d)
Hierarchical OSPF
‰ Two-level hierarchy in an OSPF AS: local area and backbone
¾ Area routers broadcasts LS advertisements to routers inside the
area
¾ Each router has detailed area topology; but the details are
invisible to the outside routers
¾ Each router only knows 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
Type
119
Connect to other ASs
Only ONE BA per AS
~ route pkts between
areas in AS
(nonborder router)
Backbone Area
route pkts to
outside area
Network Layer
120
Inter-AS
Inter-AS Routing
Routing Protocol
Protocol –– BGP4
BGP4
Inter-AS Routing Protocol – BGP4
‰ BGP (Border Gateway Protocol): the de facto standard
‰ RFC 1771-1773
‰ Supports CIDRized address (e.g., 140.124.115.0/24)
‰ Use Path Vector protocol:
¾ similar to Distance Vector protocol
¾ each Border Gateway broadcast to neighbors (peers)
entire path (i.e., sequence of AS’s) to destination
R4
R5
R3
BGP
AS1
AS2
(RIP intra-AS
routing)
(OSPF
intra-AS
routing)
BGP
R1
BGP peerR2
AS3
(OSPF intra-AS
routing)
¾ BGP routes/paths to networks (ASs), not individual
hosts/routers
¾ E.g., Gateway X may send its path to dest. Z:
Figure 4.5.2-new2: BGP use for inter-domain routing
Path (X,Z) = X,Y1,Y2,Y3,…,Z
Network Layer
121
Network Layer
IPv6
IPv6 –– IP
IP Version
Version 66
IPv6 Header
• Priority: identify priority among datagrams in flow
• Flow Label: identify datagrams in same “flow.”
(concept of“flow” not well defined).
• Next header: identify extension or upper layer protocol
‰Initial motivation: 32-bit address space completely
allocated by 2008(class B) and 2018(class C).
‰Additional motivation:
¾header format helps speed processing/forwarding
¾header changes to facilitate QoS
¾new “anycast” address: route to “best” of several
replicated servers
‰IPv6 datagram format: RFC 2460
¾fixed-length 40 byte header + extension headers
¾no fragmentation allowed
Network Layer
122
123
Network Layer
124
Headers and Order : IPv6 and Extension
IPv6 Next Header Field
0
• Next header values (Extension header)
0 ~ Hop-by-Hop Options Header
43 ~ IPv6 Routing Header
44 ~ IPv6 Fragment Header
50 ~ Encapsulating Security Payload *
51 ~ IPv6 Authentication Header *
59 ~ No Next Header
60 ~ Destination Options Header
0
31
43
44
60
EHs = n x 8B
Å D.O.H.
Authentication and encapsulating
Å security payload header (ignored)
6
(a must-be order)
• Upper-layer Protocol type identifier (new)
45 ~ Interdomain Routing Protocol
46 ~ Resource ReserVation Protocol
58 ~ IPv6 ICMP Packet
Network Layer
~ next header field
125
Network Layer
126
IPv4 and IPv6 Differences in Header
Other Changes from IPv4
• IPv6 is a static 40 bytes in length
- not variable any longer; checksum being removed
‰ 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
• IPv6 allows for jumbogrames (jumbo datagram > 65,536 bytes)
- allows for various network attachments (RFC 2146)
• IPv6 supports Extension header (concatenated headers)
• IPv4’s Total length field is replaced with payload length
• IPv4 TTL field is replaced with the hop limit
• Many IPv4 options were moved to independent protocols
Ans.: 6,3,2
* Question :
How many fields have been suppressed, renamed, and newly added ?
Network Layer
127
Network Layer
128
Dual Stack Approach
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?
‰ Two proposed basic approaches:
¾Dual Stack: some routers with dual stack (v6, v4) can
“translate” between v4 and v6 formats
A
B
C
D
E
F
IPv6
IPv6
IPv4
IPv4
IPv6
IPv6
Flow: X
Src: A
Dest: F
Src:A
Dest: F
Src:A
Dest: F
Flow: ??
Src: A
Dest: F
data
data
data
data
A-to-B:
IPv6
B-to-C:
IPv4
D-to-E:
IPv4
E-to-F:
IPv6
¾Tunneling: IPv6 carried as payload in IPv4 datagram
among IPv4 routers
Network Layer
129
Network Layer
IP Tunneling
Logical view:
Physical view:
A
B
IPv6
IPv6
A
B
C
IPv6
IPv6
IPv4
Flow: X
Src: A
Dest: F
data
A-to-B:
IPv6
Network Layer
The End
E
F
IPv6
IPv6
D
E
F
IPv4
IPv6
IPv6
tunnel
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
130
D-to-E:
IPv6 inside
IPv4
Flow: X
Src: A
Dest: F
data
Ҭ೯೽Ǻ౳࿊όӳόा໒ً
E-to-F:
IPv6
Ֆᒏψ‫ז‬Ξྗω@
131
Network Layer
132