Introduction • ICMP is often considered part of the IP layer. • It communicates error messages and other conditions that require attention. • ICMP messages are usually acted on by either IP layer or the higher layer protocol. IP header (20 byte) ICMP message IP datagram
ICMP Message • The first 4 bytes have the same format for all messages, but the remainder differs from one message to the next. 0 7 8 15 16 31 8-bit type 8-bit code 16-bit checksum (contents depends on type and code)
ICMP Echo Request and Reply • ICMP echo is a message to send and receive the specified echo data packet between two TCP/IP nodes. 0 7 8 15 16 31 Type(0 or 8) Code(0) checksum identifier sequence number Echo data (variable length)
ICMP Addr Mask Request and Reply • The ICMP Address mask request is intended for a diskless system to obtain its subnet mask at bootstrap time. 0 7 8 15 16 31 Type(17 or 18) Code(0) checksum identifier sequence number 32-bit subnet mask
ICMP Addr Mask • We can write a simple program that issues an ICMP address mask request and prints all replies. % icmpaddrmask 18.104.22.168 Received mask = ffffffe0, from 22.214.171.124 Received mask = ffffffe0, from 126.96.36.199 Received mask = ffff0000, from 188.8.131.52
ICMP Timestamp Request and Reply • The ICMP timestamp request allows a system to query another for the current time. • The recommended value to be returned is the number of milliseconds since midnight, Coordinated Universal Time (UTC). 0 7 8 15 16 31 Type(13 or 14) Code(0) checksum identifier sequence number 32-bit originate timestamp 32-bit receive timestamp 32-bit transmit timestamp
ICMP Timestamp Request and Reply • The requestor fills in the originate timestamp and sends the request. • The replying system fills in the receive timestamp when it receives the request. • The transmit timestamp when it send the reply. 0 7 8 15 16 31 Type(13 or 14) Code(0) checksum identifier sequence number 32-bit originate timestamp 32-bit receive timestamp 32-bit transmit timestamp
ICMP Unreachable Message • It is an error message sent back to the transmission origin when the packet cannot be sent to service. • It is likely to reply from a machine on the way of routing (router), and it might reply from the machine (target host). 0 7 8 15 16 31 Type(3) Code(0-15) checksum Unused (must be 0) IP header + first 8 bytes of original IP datagram data
Exercises • If your system provides the netstat command, use it to see what types of ICMP messages are received and sent.
Introduction • The name “ping” is taken from the sonar operation to locate objects. • The program sends an ICMP echo request message to a host, expecting an ICMP echo reply to be returned. • Ping also measures the round-trip time to the host, giving us some indication of how “far away” that host is.
(1) (2) (3)
Ping HOST B 192.168.1.2 HOST A 192.168.1.1 - Ping 192.168.1.2 Please return the sent data. I return the data as it is. - Reply from 192.168.1.2 : bytes = 32 time < 10ms TTL = 128
Format of ICMP message • We call the ping program that sends the echo requests the client, and the host being pinged the server. 0 7 8 15 16 31 Type(0 or 8) Code(0) checksum identifier sequence number Optional data
From the result • The network communication with the object host must be normal. • Own host's network setting and operation. • The object host's network setting and operation. • Setting and operation of network/router. • Network performance • The throughput of the network can guess from the display of statistics.
Case of failure • The routing to Internet Protocol address cannot be done. C:\>ping 192.168.10.1Pinging 192.168.10.1 with 32 bytes of data:Reply from 184.108.40.206: Destination net unreachable.Reply from 220.127.116.11: Destination net unreachable.Reply from 18.104.22.168: Destination net unreachable.:
Case of failure • Loop by routing setting mistake. C:\>ping 150.224.XXX.XXXPinging 150.224.XXX.XXX with 32 bytes of data:Reply from 130.XXX.76.17: TTL expired in transit.Reply from 130.XXX.76.17: TTL expired in transit.Reply from 130.XXX.76.17: TTL expired in transit.Reply from 130.XXX.76.17: TTL expired in transit.Ping statistics for 150.224.XXX.XXX: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms
Case of failure • Failure of host name resolution. • The host's stop. C:\>ping www.unknown.netUnknown host www.unknown.net. C:\>ping host1.example.netPinging host1.example.net [211.XXX.XXX.190] with 32 bytes of data:Request timed out.Request timed out.:
Summary • The ping program is the basic connectivity test between two systems running TCP/IP. • It uses the ICMP echo request and echo reply messages and does not use a transport layer. • Ping also let us examine and use the IP record route option.
Exercises • Calculate the RTT if the SLIP link between bsdi and slip is set to 9600 bits/sec. Assume the default of 56 bytes of data.
Normal Access IP ICMP HOST X HOST A Because of router Couldn’t find Host X, router send a Error Message Destination unreachable Echo Request ICMP ICMP HOST Y HOST B Echo Reply
ICMP Message Types • When an ICMP error message is sent, the message always contains the IP header and the first 8 bytes of the IP datagram that caused the ICMP error to be generated. • This lets the receiving ICMP module associate the message with one particular protocol and one particular user process.
ICMP Message Types • An ICMP error message is never generated in response to • An ICMP error message • A datagram destined to an IP broadcast address or an IP multicast address. • A datagram sent as a link-layer broadcast. • A fragment other than the first. • A datagram whose source address does not define a single host.