Chs6-8min

advertisement
Chapter 6 – Internet Protocol: Connectionless Datagram Delivery
6.3 Internet Architecture and Philosophy
Various later chapters about these
Chapter 12 will be about this layer
Chapters 6 - 8 are about this layer
NETWORK INTERFACE (MAC) LAYER
Not part of IP
1
SMTP,
HTTP, etc.
TCP
IP
6.5 Connectionless Delivery System
Internet Protocol (IP) is an
► unreliable (best-effort) (but some errors are reported)
► connectionless packet delivery service
(compare wired Ethernet)
6.6 Purpose of the Internet Protocol
Chapter 6 – Packet format
Chapter 7 – Forwarding
Chapter 8 – Error messages
2
Figure 6.3 Format of an IP Datagram
3
ORIGINAL
ULTIMATE
Figure 6.3 Format of an IP Datagram
4
6.7.3 Datagram Encapsulation
5
0800
IP DATAGRAM
Figure 2.2 Ethernet Frame Format
6
6.7.4 (Payload) Fragmentation
Figure 6.7 Where Fragmentation Occurs
7
Figure 6.8 (a) Original Datagram carrying 1400 octets of data
(b) For a network MTU of 620 the data are fragmented between
three new datagrams.
They must be complete datagrams, with header!
8
6.7.5 Reassembly of Fragments
Where to reassemble the payload?
How to reassemble the payload?
9
MF
1
1
0
10
11
12
Chapter 7 IP: Forwarding IP Datagrams
Routers make forwarding decisions.
Hosts also make forwarding decisions.
sender
HOST
Fig 7.1 – blue host has three possible choices
when transmitting a datagram
13
7.3 Direct and Indirect Delivery of an IP Datagram
Direct: No router between source and destination
Indirect: sender must be able to identify first router in chain
Q: How does sender know that direct delivery is possible?
A: network parts of source and destination IP addresses
are identical.
14
7.3.1 Datagram Delivery over a Single Network
Last router in chain must deliver directly
Indirect delivery is a concatentation of direct deliveries;
Alternatively, direct delivery is the trivial case of indirect delivery.
15
7.4 Table-Driven IP Forwarding
Routers store their forwarding instructions in “routing tables.”
Hosts also have routing tables, but they are small.
7.5 Next-Hop (Next-Stop?) Forwarding
A routing table contains pairs (N,R) where N is the IP address of a
destination network and R is the IP address of the “next” router along
the path to N.
The “next hop” must be a directly-connected router.
A router knows only the “next hop” along the way,
not the complete path to the destination.
16
Fig. 7.2(b) the routing table in R
Size of routing table is proportional to
number of networks.
17
BHM
CHL
NO
ATL
Routes are chosen only on basis of destination network
Consequences of choosing routes based only on the destination network:
► all traffic from a source to a given destination follows the same
path; multiple paths may not be followed concurrently.
► only the final router along the path can know if the destination
is operational (for Ethernet, not even the final router).
► forward and reverse paths may be different.
18
7.6 Default Routes
Routing table in Q:
10.0.0.0
Deliver Directly
20.0.0.0
Deliver Directly
Default
Forward to
20.0.0.6
Huge benefit!
Entire external Internet can often be collapsed
into a single entry!
19
7.8 The IP Forwarding Algorithm
Check IP Version and checksum !
Fig 7.3
20
Forwarding Algorithm (revised)
Check IP version and header checksum
Extract destination IP address, D, from the datagram;
if table contains a host-specific route for D
send datagram to next-hop specified in table (ENCAPSULATE) and quit;
compute N, the network prefix of address D;
if N matches any directly-connected network address
deliver datagram to destination D over that network (ENCAPSULATE);
else if table contains a route for network prefix N
send datagram to next hop specified in table (ENCAPSULATE);
else if table contains a default route
send datagram to default router specified (ENCAPSULATE);
else declare a forwarding error;
ENCAPSULATE = map IP address to a physical address,
encapsulate the datagram in a frame and send.
21
compute N, the network prefix of address D;
4.11 Dotted Decimal Notation
10001010
138
00011010
.
26
01000010
.
00000110
66
.
6
10001010
00011010
01000010
00000110
11111111
11111111
00000000
00000000
255
.
255
.
0
“Address Mask”
.
0
22
Elaboration of routing algorithm (figure 7.3, or revision):
“if table contains a route for network prefix N
send datagram to next hop specified in table;”
Recall forwarding table:
Notation: Table row contains
(destination network IP address, next hop IP address)
Algorithm is:
For each row of the forwarding table
If (address mask) .and. IPD = destination network IP address
then send datagram to next hop IP address
exit routing algorithm.
23
7.9 Forwarding with IP Addresses
which fields are changed by router?
After table-lookup has determined the next-hop IP address,
where in the IP datagram does the router IP layer store it?
In Destination IP Address?
Nowhere!
The router simply passes the next-hop IP
address down to the network interface layer
for ARP processing.
24
Why not use physical addresses when storing
and computing routes?
01:FA:96:43:1B:49
02:16:7B:62:78:F3
25
Why does IP software avoid using physical
addresses when storing and computing routes?
Figure 7.4
Using only IP addresses above the dashed line makes routes
easy to examine or change and hides the details of the
underlying physical networks.
26
7.10 Handling Incoming Datagrams
Hosts
IP layer checks its own IP address against the destination IP address in the
arriving datagram.
If match, OK
else host discards datagram.
Why discard?
► there has been an error and if host forwards the
datagram to the correct destination, error will persist;
► we don’t want the host to be diverted from its legitimate work
to do the router’s work.
27
7.10 Handling Incoming Datagrams – continued
Routers
Check all of own IP addresses against the destination IP address in
incoming datagram.
If no match (usual situation)
router is a stop along the way from source to destination –
execute forwarding algorithm (fig 7.3)
else
router is final destination of this datagram – message is for
higher layer within the router, eg. routing table change
28
7.11 Establishing Routing Tables
For now, assume routing tables are loaded manually;
In chapters 13 and 15 we’ll see protocols that allow routers to learn
routes from each other.
End of Chapter 7.
29
Summary of Bridge
1. Like computer with 2 NICs in
promiscuous mode
Summary of Router
1. Like computer with 2 NICs in
normal mode
2. Store and forward frames
2. Store and forward IP datagrams
3. Processes only valid frames
3. Processes only valid IP datagrams
4. Works at layer 2 with
hardware addresses
4. Works at layer 3 with IP addresses
5. Automatically learns which
destination hosts are
reachable from which
interface (no administrator
required).
5. Administrator has to enter next hop
in routing tables.
6. Does not change frame in
any way (bridges “leave no
fingerprints”)
6. When forwarding IP datagram,
changes at least two fields in
datagram header
7. Forwards frames with local
broadcast hardware address
in destination-address field
7. Does not forward IP datagrams with
local broadcast IP address in 30
destination-address field
Perspective on Comer’s Chapters 6 – 8
Chapter 6 - Internet Protocol: Connectionless Datagram Delivery
no routers necessarily involved – lab sessions 1 - 3
Chapter 7 - Internet Protocol: Forwarding IP Datagrams
how routers work – lab session 4
Chapter 8 – Internet Protocol: Error and Control Messages (ICMP)
PING in lab sessions 1 – 3, will see more in later labs.
31
Chapter 8 – Internet Protocol: Error and Control Messages
(ICMP)
8.2 The Internet Control Message Protocol
ICMP is a required part of IP.
Although IP does not guarantee delivery, it does not
capriciously discard datagrams and when it is forced to do
so it tries to be helpful by sending an ICMP message.
Both routers and hosts send ICMP messages.
32
8.2 The Internet Control Message Protocol – contd.
Like all traffic across an IP network, ICMP messages travel in the
payload of an IP datagram.
1
ICMP Message
The ultimate destination of an ICMP message is the IP software on the
machine intended to receive the message – it is the IP software that has
the code to handle the message.
33
8.3 Error Reporting vs. Error Correction
Not all ICMP messages relate to errors – eg. PING.
For errors, ICMP is a reporting mechanism,
not a correcting mechanism.
When a datagram causes an error, the unit detecting this usually sends an
ICMP message back to the original source of the datagram, stating why the
datagram was dropped.
Why is notification restricted to the original source?
That’s all
the
detecting
unit
knows!
34
8.4 ICMP Message Delivery
Datagrams carrying ICMP messages are subject to the usual
IP uncertainty.
Exception: If a datagram carrying an ICMP error message
encounters difficulty, an error message about this error
message is not sent.
ICMP is not considered a higher-layer protocol –
it is part of IP
35
8.5 ICMP Message Format
Although each ICMP message has its own format, they all
begin with the same three fields:
ICMP messages that report errors always include the
header plus additional octets from the IP datagram that
caused the problem
36
Error?
No
Yes
Yes
Yes
?
No
?
?
Yes
Figure 8.2 Values that can appear in the TYPE field of an ICMP message
37
8.6 Testing Destination Reachability and Status (Ping)
Type 8 is request, type 0 reply.
IDENTIFIER is a random number, used to match
replies with requests.
Will be studied in Lab Session #1
38
8.8 Reports of Unreachable destinations
When a router cannot forward or deliver an IP datagram, the router
sends an ICMP destination unreachable (type 3) message back to
the original source.
39
8.8 Reports of Unreachable destinations - continued
*
* Code 4 used for path MTU discovery
40
Comer page 116:
A router may not know of all delivery failures,
eg. final delivery over Ethernet.
From revised version of routing algorithm (fig 7.3):
compute N, the network prefix of address D;
if N matches any directly-connected network address
deliver datagram to destination D over that network
(ENCAPSULATE);
ENCAPSULATE = map IP to a physical address, encapsulate
the datagram in a frame and send.
No feedback to IP if ARP fails.
41
8.11 Route Change Requests from Routers
Fig 7.1
If router R2 receives a datagram that it has to forward to R1, R2
sends an ICMP redirect message (type 5) to the sending host,
telling it in future to send such datagrams directly to R1.
42
8.11 Route Change Requests from Routers – continued
This is not a general mechanism for route changes. It is restricted
to routers sending to directly-connected hosts.
Figure 8.7
R5 cannot redirect R1 to use the shorter path from S to D
43
8.12 Detecting Circular or Excessively Long Routes
Each time a router forwards a datagram it decrements the TTL by 1
If the result is zero, the router discards the datagram after sending an ICMP
time exceeded (type 11, code 0) message.
When a destination host reassembles a fragmented payload, it’s possible
that some fragments are lost.
When the host receives the first fragment it starts a reassembly timer.
If the timer expires before all fragments arrive, the host gives up and sends
an ICMP type 11, code 1 message back to the original source.
44
45
2 binary inputs A, B
Output
A
.AND. B
Input
MaskA
IP Destination
Input
B
Address
Output
0
0
0
0
1
0
1
0
0
1
1
1
46
2 binary inputs A, B
Output
.OR. B
Input A
Input B
Output
0
0
0
0
1
1
1
0
1
1
1
1
A
47
Download