Chapter 4: Introduction to the Internet Protocol (IP)

Download Report

Transcript Chapter 4: Introduction to the Internet Protocol (IP)

Chapter 4
Network Layer 3:
The Internet Protocol (IP)
Professor Rick Han
University of Colorado at Boulder
[email protected]
Announcements
• Reminder: Programming assignment #1 is due
Feb. 19
• Part of Homework #2 available later today
on Web site, the traceroute part will be
available Monday
• Homework #1 solutions when we hand back
graded Homework #1
• Reading Chapter 4
•
•
4.1 today + added material
4.2, 4.3, 4.4 in same order
• Next, IP network, packets, ARP, RARP, …
Prof. Rick Han, University of
Colorado at Boulder
Recap of Previous Lecture
• Interconnecting Ethernet LANs
•
Ethernet Bridges/Switches – Layer 2
• Loops can form, causing:
• Packet multiplication
• Endless Looping
• Solution: Create Spanning Trees
• Eliminates Loops and Spanning Trees
• Interconnecting Hosts and Switches via Pointto-Point Links
•
Asynchronous Transfer Mode (ATM)
• Virtual circuits to route packets
Prof. Rick Han, University of
Colorado at Boulder
ATM Network
• Switch packets via virtual circuit routing
• Lost to Ethernet in LAN, Losing to Gig. Eth./
SONET in MAN, SONET/MPLS in WAN
•
•
Cost and complexity
But, some customers (DSL) want AAL’s guaranteed
QOS for voice/video
Switch
C
Switch
Host A
B
Host F
Switch
D
Switch
E
Prof. Rick Han, University of
Colorado at Boulder
Frame Relay and X.25
• Frame Relay:
•
•
•
Like ATM, uses permanent virtual circuits (PVCs –
more common) and SVCs
Widely deployed in 1990s
No error recovery per link – not necessary over
optical fiber
• X.25 is an old 1970s “public packet switching”
technology
•
•
Like ATM, uses virtual circuits to interconnect
“dumb” terminals
Error recovery on each link, due to noisy copper
phone lines
Prof. Rick Han, University of
Colorado at Boulder
Bridging to Connect Remote LANs?
• Network “Cloud” could be one giant bridge
•
•
Switch B keeps Ethernet MAC header,
encapsulates Ethernet frame with network
header, Switch E strips away network header
spanning tree and a bridge table within cloud
Ethernet 1
ATM or Frame Relay Network
Switch
B
Switch
C
Switch
D
Prof. Rick Han, University of
Colorado at Boulder
Switch
E
Ethernet 2
Bridging to Connect Remote LANs?
(2)
• Problems:
•
•
Many different types of LAN’s, e.g. Token Ring
and FDDI, with completely different addressing
schemes
Spanning tree doesn’t scale well
Ethernet 1
ATM or Frame Relay Network
Undecipherable?
Switch
B
Switch
C
Switch
D
Prof. Rick Han, University of
Colorado at Boulder
Switch
E
Token Ring
Routing to Connect Remote LANs
• Internet Protocol (IP) addressing is the glue
that spans heterogeneous LANs and WANs
• IP hosts send IP packets via IP routers
(shown in yellow)
ATM/Frame Relay
Router
X
Host 1
Switch
B
Switch
C
Switch
D
Prof. Rick Han, University of
Colorado at Boulder
Router
Y
Switch
E
Host
2
Routing to Connect Remote LANs (2)
Host 1
Router X
IP
Eth.
MAC
Phys.
Router Y
IP
Eth.
MAC
Phys.
IP
ATM
ATM
Link
Link
Phy
ATM
Net.
Phy
Prof. Rick Han, University of
Colorado at Boulder
Host 2
IP
Tok R
MAC
Tok R
MAC
Phys.
Phys.
Routing to Connect Remote LANs (3)
• Alternatively, IP directly over SONET (MANs)
•
•
Link-layer framing over fiber
Less overhead: (IP over SONET) vs. (IP over ATM
over link layer (could be SONET))
IP over SONET
Router
X
Router
SONET
B
SONET
Router
C
SONET SONET
Host 1
Router
D
SONET
Router
SONET Y
SONET Router
E
Prof. Rick Han, University of
Colorado at Boulder
Host
2
Routing to Connect Remote LANs (4)
Host 1
Router X
IP
Eth.
MAC
Router Y
IP
Eth.
MAC
IP
SONET
framing
SONET Tok R
framing MAC
Host 2
IP
Tok R
MAC
IP Opt Fbr
Opt
Fbr
Phys.
Phys.
Phys.
Phys.
Net.
OC-?
OC-?
• OC3=155 Mbps, OC12=622 Mbps, OC48=2.488 Gbps,
OC192=10 Gbps
• Competitors to SONET
in MAN: Gigabit Ethernet
Prof. Rick Han, University of
Colorado at Boulder
Internet Backbone
Take this with a grain of salt: can be a highly
political prediction of what someone wants to happen
Prof. Rick Han, University of
Colorado at Boulder
UUNet/WorldCom
Backbone Provider
To ISP’s:
• Leader at 28%
market share
Claim: there’s a
bandwidth glut on
the backbone:
~1% bandwidth
utilization
Prof. Rick Han, University of
Colorado at Boulder
AT&T SONET Backbone
Prof. Rick Han, University of
Colorado at Boulder
Internet Topology
ISP
Internet Service
Provider
ISP
Host 2
Host 1
POP
POP
Point of Presence
Network
Access Point
Backbone
Provider
NAP
Backbone
Provider
Also called NSP:
Prof. Rick Han, University of Network Service Provider
Colorado at Boulder
Internet Routing
• For simplicity, assume an Internet with a
homogeneous IP backbone. IP provides:
•
Unreliable out-of-order datagram delivery, also
called “best-effort” service - no QOS guarantees,
just First-Come-First-Serve (FCFS) routing
IP backbone
Router
X
Host 1
Router
B
Router
C
Router
D
Prof. Rick Han, University of
Colorado at Boulder
Router
Y
Router
E
Host
2
Internet Protocol Packet Format
IP Datagram
IP Header
Data (variable length)
Prof. Rick Han, University of
Colorado at Boulder
IP Packet Header
• Big endian/network byte order: send lower order
bytes first
•
Send bits 0-7, then 8-15, then …
•
proposal for IPv6, which will have a different header
• Version: current version is 4, I.e. IPv4
Prof. Rick Han, University of
Colorado at Boulder
IP Packet Header (2)
• IHL: header length in # 32-bit words
•
•
•
Normally = 5, i.e. 20 byte IP headers
Max 60 bytes
Header can be variable length
Prof. Rick Han, University of
Colorado at Boulder
IP Packet Header (3)
• Type of Service: 3-bit precedence field
(unused), 4 TOS bits, 1 unused bit set to 0
•
•
•
TOS bit 1 (min delay), 2 (max throughput), 3 (max
reliability), 4 (min cost): only one can be set
typically all are zero, for best-effort service
DiffServ proposes to use TOS for IP QOS
Prof. Rick Han, University of
Colorado at Boulder
IP Packet Header (4)
• Total Length: of datagram, in bytes
•
Max size is 65535 bytes
•
Used for fragmentation and reassembly
• Identification: uniquely identifies each
datagram sent by a host
Prof. Rick Han, University of
Colorado at Boulder
IP Packet Header (5)
• Flags & Fragment Offset: for fragmentation
• Time To Live: upper limit on # routers that a
datagram may pass through
•
Initialized by sender, and decremented by each
router. When zero, discard datagram. Stops looping
Prof. Rick Han, University of
Colorado at Boulder
IP Packet Header (6)
• Protocol: IP needs to know to what protocol it
should hand the received IP datagram
•
demultiplexes incoming IP datagrams into either
UDP, TCP, ARP, …
Prof. Rick Han, University of
Colorado at Boulder
IP Packet Header (7)
• Header Checksum: calculated only over header
•
•
At sender, set to 0. Compute one’s complement 16bit sum. Insert 16-bit one’s complement of this sum.
At receiver, compute 16-bit one’s complement sum
of header – should be all 1’s. If not, discard
Prof. Rick Han, University of
Colorado at Boulder
IP Packet Header (8)
• Source and Destination IP address: 32 bits long
each:
•
•
Often see written like, 12.244.92.161
• 127.0.0.1 is localhost loopback address, i.e. yourself
Various classes of IP addresses
Prof. Rick Han, University of
Colorado at Boulder
IP Addressing
• Destination address is the key to packet
routing:
•
IP routers only look at where the packet is headed,
rather than where it came from
• Source address is useful:
•
•
At receiver, to decide whether to accept incoming
packet
At receiver, to send acknowledgement back to
sender, e.g. TCP sends its acknowledgements
• IP address is per interface, so a given router
with N interfaces can have N IP addresses
Prof. Rick Han, University of
Colorado at Boulder
IP Addressing (2)
• IP addresses are hierarchical: 12.244.92.161
• Class A
• Class B
• Class C
0
7
24
Network
Host
16
14
1
0 Network
21
1 1 0 Network
Host
8
Host
• Hierarchy to handle WANs, MANs, and LANs:
•
•
Class C allows for only 256 local hosts, but 221 Class
C networks – for small office nets
24 local hosts, few 27 networks
Class A allows many
2
Prof. Rick Han, University of
Colorado at Boulder
IP Addressing (3)
• Classes impose fixed-size network sub-fields
that may not suit an organization’s needs =>
waste much address space
•
•
Phase out fixed classes A, B, C
Solution: classless routing, or Classless Interdomain
Routing (CIDR), 1993
• Network sub-field can have any number of bits
• a.b.c.d/x is CIDR notion for an IP address a.b.c.d
with first x bits as network address
Prof. Rick Han, University of
Colorado at Boulder
IP Addressing (4)
• Assigning IP addresses:
•
•
Automatically: via Dynamic Host Configuration
Protocol (DHCP) – we’ll study it later
Manually:
• Contact your ISP
• an organization contacts its ISP for a block of
allocated IP addresses
• An ISP contacts one of several well-known global
registries (originally managed by IANA alone)
• 4 billion possible addresses
•
•
•
Running out?
NAT (Network Address Translation) ease the
pressure – we’ll study it later
Prof. Rick Han, University of
IPv6
Colorado at Boulder
IP Fragmentation and Reassembly
• Fragmentation occurs when datagram exceeds
MTU of underlying network
•
Ethernet MTU is 1500 bytes, FDDI MTU is 4500
bytes
• Identifier field uniquely identifies a datagram
sent from a source
• Set M bit in Flags field to one to indicate more
fragments to follow
• Set Offset to 0 for first fragment
•
•
For second fragment, set Offset = length of data in
first fragment
For N’th fragment, set Offset = sum of lengths of
data in N-1 fragments
Prof. Rick Han, University of
Colorado at Boulder
IP Fragmentation and Reassembly
(2)
• For last fragment, set M in Flags field to 0, to
indicate no more fragments
• Each IP fragment is a full-fledged datagram
• Reassembly:
•
•
•
Fragments can be lost
After waiting a “reasonable” amount of time, an IP
end host will stop reassembly
To avoid this waiting delay due to lost fragments,
the sending host should perform path MTU
discovery prior to sending IP packets, and then send
at the MTU of the path
Prof. Rick Han, University of
Colorado at Boulder
Address Resolution Protocol
(ARP)
• How does IP sends its packet over Ethernet?
•
•
Ethernet doesn’t understand 32-bit addresses
Need to map 32-bit to Ethernet’s “physical” 48-bit
addresses
• Each host builds a cache that maps IP
addresses to Ethernet addresses – distributed,
not centralized
• If sending to a host on the same Ethernet,
•
•
First, check cache if address already present
If not, send an Ethernet’s broadcast query (all 1’s in
48-bit address), frame’s Type field set to ARP
• Query contains “target” IP address, and link
layer address
of sending host
Prof. Rick Han, University of
Colorado at Boulder
Address Resolution Protocol (2)
• Each host receives broadcast query and checks
to see if target IP address matches its own
•
If match, sends a response to link-layer address of
originator, containing its own link-layer address
• When another host hears an ARP request
•
•
If requester is in cache, then refresh its own cache
• Entries in ARP cache time out ~ every 15 min
If requester is not in cache
• If host is target, then add to cache
• Otherwise don’t add to cache, to keep ARP table
clean
Prof. Rick Han, University of
Colorado at Boulder