ICMPは、IPから見ると上位のプロトコルだが、機能的にはOSI基本参照モデルの第3層(ネットワーク層)に類別される。
ICMPのパケットフォーマット
rfc792
Introduction:
The Internet Protocol (IP) is used for host-to-host datagram service in a system of interconnected networks called the Catenet. The network connecting devices are called Gateways. These gateways communicate between themselves for control purposes via a Gateway to Gateway Protocol (GGP). Occasionally a gateway or destination host will communicate with a source host, for example, to report an error in datagram processing. For such purposes this protocol, the Internet Control Message Protocol (ICMP), is used. ICMP, uses the basic support of IP as if it were a higher level protocol, however, ICMP is actually an integral part of IP, and must be implemented by every IP module.
ICMP messages are sent in several situations: for example, when a datagram cannot reach its destination, when the gateway does not have the buffering capacity to forward a datagram, and when the gateway can direct the host to send traffic on a shorter route.
The Internet Protocol is not designed to be absolutely reliable. The purpose of these control messages is to provide feedback about problems in the communication environment, not to make IP reliable. There are still no guarantees that a datagram will be delivered or a control message will be returned. Some datagrams may still be undelivered without any report of their loss. The higher level protocols that use IP must implement their own reliability procedures if reliable communication is required.
The ICMP messages typically report errors in the processing of datagrams. To avoid the infinite regress of messages about messages etc., no ICMP messages are sent about ICMP messages. Also ICMP messages are only sent about errors in handling fragment zero of fragemented datagrams. (Fragment zero has the fragment offeset equal zero).
Message Formats:
ICMP messages are sent using the basic IP header. The first octet of the data portion of the datagram is a ICMP type field; the value of this field determines the format of the remaining data. Any field labeled "unused" is reserved for later extensions and must be zero when sent, but receivers should not use these fields (except to include them in the checksum). Unless otherwise noted under the individual format descriptions, the values of the internet header fields are as follows:Version4IHLInternet header length in 32-bit words.Type of Service0Total LengthLength of internet header and data in octets.Identification, Flags, Fragment OffsetUsed in fragmentation.Time to LiveTime to live in seconds; as this field is decremented at eachmachine in which the datagram is processed, the value in thisfield should be at least as great as the number of gateways whichthis datagram will traverse.ProtocolICMP = 1Header ChecksumThe 16 bit one's complement of the one's complement sum of all 16bit words in the header. For computing the checksum, the checksumfield should be zero. This checksum may be replaced in thefuture.Source AddressThe address of the gateway or host that composes the ICMP message.Unless otherwise noted, this can be any of a gateway's addresses.Destination AddressThe address of the gateway or host to which the message should besent.
Destination Unreachable Message
Type
3
Code
0 = net unreachable;
1 = host unreachable;
2 = protocol unreachable;
3 = port unreachable;
4 = fragmentation needed and DF set;
5 = source route failed.
Time Exceeded Message
Type
11
Code
0 = time to live exceeded in transit;
1 = fragment reassembly time exceeded.
Redirect Message
Type
5
Code
0 = Redirect datagrams for the Network.
1 = Redirect datagrams for the Host.
2 = Redirect datagrams for the Type of Service and Network.
3 = Redirect datagrams for the Type of Service and Host.
Echo or Echo Reply Message
Type
8 for echo message;
0 for echo reply message.
Code
0
ICMPの利用例
ICMP利用例 | 送信元のホスト | 経路上のルータ | 目標のホスト |
---|---|---|---|
pingコマンド | エコー要求(タイプ:8) | 宛先到達不能(タイプ:3) | エコー応答(タイプ:0) |
tracerouteコマンド | IPヘッダのTTLを1つずつ増やしてパケットを送信 | 時間超過(タイプ:11) | - |
経路MTU | IPヘッダのDFビットを設定してパケットを送信 | 宛先到達不能(タイプ:3、コード:4) | - |
0 件のコメント:
コメントを投稿