CSC521 Communication Protocols 網路通訊協定 Ch.9 Internet Protocol: Error And Control Messages (ICMP) 吳俊興國立高雄大學資訊工程學系 Internetworking With TCP/IP, Vol I: Sixth Edition, Douglas E. Comer
Outline 1 Introduction 2 The Internet Control Message Protocol 3 Error Reporting Vs. Error Correction 4 ICMP Message Delivery 5 Conceptual Layering 6 ICMP Message Format 7 Example ICMP Message Types Used With IPv4 And IPv6 8 Testing Destination Reachability And Status (Ping) 9 Echo Request And Reply Message Format 10 Checksum Computation And The IPv6 Pseudo-Header 11 Reports Of Unreachable Destinations 12 ICMP Error Reports Regarding Fragmentation 13 Route Change Requests From Routers 14 Detecting Circular Or Excessively Long Routes 15 Reporting Other Problems 16 Older ICMP Messages Used At Startup 17 Summary 2
Error Detection and Reporting Mechanisms Errors in Packet Switching Networks Temporary or permanent disconnection Hardware failures Router overrun Routing loops Need mechanisms to detect and correct Error handling IP header checksum to detect transmission errors Error reporting mechanism to distinguish between events such as lost datagrams and incorrect addresses Higher level protocols (i.e., TCP) must handle all other problems 3
Error Reporting Mechanism Internet Control Message Protocol (ICMP) Required and integral part of IP Used primarily by routers to report delivery or routing problems to original source Also includes informational (non-error) functionality Uses IP to carry control messages No error messages sent about error messages Purpose The Internet Control Message Protocol allows a router to send error or control messages to the source of a datagram, typically a host. ICMP provides communication between the Internet Protocol software on one machine and the Internet Protocol software on another. 4
Important Restrictions of ICMP ICMP only reports problems to original source Provide interaction between a router and the source of trouble Error Reporting vs. Error Correction: ICMP does not Maintain state information (each packet is handled independently) Thus: when a datagram causes an error, ICMP can only report the error condition back to the original source of the datagram; the source must relate the error to an individual application program or take other action to correct the problem 5
ICMP Encapsulation ICMP message travels in IP datagram ICMP message has header and data area Complete ICMP message is treated as data in IP datagram Complete IP datagram is treated as data in physical network frame 6
Two sets of ICMP messages a set for IPv4 a larger set for IPv6 In both versions of IP ICMP Message Format Each ICMP message has its own format All ICMP messages begin with the same three fields 7
Example ICMP Message Types Used With IPv4 8
Example ICMP Message Types Used With IPv6 9
ICMP Message Format Multiple message types Each message has its own format Messages Begin with 1-octet TYPE field that identifies which of the basic ICMP message types follows Some messages have a 1-octet CODE field that further classifies the message Example Encapsulation In Ethernet ICMP header follows IP header, and contains eight bytes ICMP type field specifies echo request message (08) TYPE specifies destination unreachable CODE specifies whether host or network was unreachable ICMP sequence number is zero 10
Example ICMP Message Example: ICMP Echo Request Sent by ping program to test destination reachability and status Request: Type=8 Reply: Type=0 11
Checksum Computation And The IPv6 Pseudo-Header Pseudo-header and the use of dashed lines is merely used for the checksum computation and is never placed in a packet 12
ICMP Echo Request Example 192.168.0.31 74.125.23.94 13
ICMP Echo Reply Example 192.168.0.31 74.125.23.94 14
Example ICMP Message Example: Destination Unreachable Used by a router to report that datagram could not be delivered Code specifies details 15
A router Reports Of Unreachable Destinations Drops (i.e., discards) the datagram whenever an error occurs in a datagram sends an ICMP destination unreachable message back to the source 16
ICMP Error Reports Regarding Fragmentation Both IPv4 and IPv6 allow a router to report an error when a datagram is too large for a network over which it must travel and cannot be fragmented Type=3: Destination Unreachable Code=4: Fragmentation Needed and DF Set 17
Example: Time Exceeded Example ICMP Message At least one fragment failed to arrive, or TTL field in IP header reached zero Code=0: Time-to-live count exceeded Code=1: Fragment reassembly time exceeded 18
ICMP Trick Include datagram that caused problem in the error message Efficient (sender must determine how to correct problem) Eliminates need to construct detailed message Problem: entire datagram may be too large Solution: send IP header plus 64 bits of data area (sufficient in most cases) 19
Route Change Requests From Routers Host s Forwarding table A host initializes its forwarding table at system startup System administrators seldom change the table during normal operation The host relies on routers to update its forwarding table as needed Router s Forwarding table Routers exchange routing information periodically A router only sends a redirect message if the host sends a datagram along a non-preferred route 20
Route Change Requests From Routers 21
Example: Redirect Example ICMP Message Used by a router to report incorrect route Suggesting the source host to redirect the attached IP datagram Code Meaning 0 Redirect datagrams for the Net (now obsolete) 1 Redirect datagrams for the Host 2 Redirect datagrams for the Type of Service and Net 3 Redirect datagrams for the Type of Service and Host 22
DHCP Older ICMP Messages Used At Startup Originally defined in a set of messages that a host used at startup to determine its IP address, the address of a router, and the address mask used on the network Router Discovery message At startup, an IPv6 host multicasts an ICMPv6 Router Discovery message to learn about routers on the local network Two conceptual differences between router discovery and DHCP With router discovery, there is never a third-party error; with DHCP, such errors are possible ICMP router discovery uses a soft state technique with timers to prevent hosts from retaining a forwarding table entry after a router crashes 23
ICMP Required part of IP Used to report errors to original source Reporting only: no interaction or error correction ICMP encapsulated in IP for delivery Several ICMP message types, each with its own format ICMP message begins with 1-octet TYPE field Examples Summary Echo Request/Reply, Destination Unreachable, Time Exceeded, Redirect, NDP/DHCP, etc. 24