Internet Control Message Protocol

Last updated
Internet Control Message Protocol
Communication protocol
ICMP header - General-en.svg
A general header for ICMPv4
PurposeAuxiliary protocol for IPv4 [1]
Developer(s) DARPA
Introduction1981
OSI layer Network layer
RFC(s) RFC 792

The Internet Control Message Protocol (ICMP) is a supporting protocol in the Internet protocol suite. It is used by network devices, including routers, to send error messages and operational information indicating success or failure when communicating with another IP address. For example, an error is indicated when a requested service is not available or that a host or router could not be reached. [2] ICMP differs from transport protocols such as TCP and UDP in that it is not typically used to exchange data between systems, nor is it regularly employed by end-user network applications (with the exception of some diagnostic tools like ping and traceroute).

Contents

ICMP for IPv4 is defined in RFC   792. A separate ICMPv6, defined by RFC 4443, is used with IPv6.

Technical details

ICMP is part of the Internet protocol suite as defined in RFC 792. ICMP messages are typically used for diagnostic or control purposes or generated in response to errors in IP operations (as specified in RFC 1122). ICMP errors are directed to the source IP address of the originating packet. [2]

For example, every device (such as an intermediate router) forwarding an IP datagram first decrements the time to live (TTL) field in the IP header by one. If the resulting TTL is 0, the packet is discarded and an ICMP time exceeded message is sent to the datagram's source address.

Many commonly used network utilities are based on ICMP messages. The traceroute command can be implemented by transmitting IP datagrams with specially set IP TTL header fields, and looking for ICMP time exceeded in transit and destination unreachable messages generated in response. The related ping utility is implemented using the ICMP echo request and echo reply messages.

ICMP uses the basic support of IP as if it were a higher-level protocol, however, ICMP is actually an integral part of IP. Although ICMP messages are contained within standard IP packets, ICMP messages are usually processed as a special case, distinguished from normal IP processing. In many cases, it is necessary to inspect the contents of the ICMP message and deliver the appropriate error message to the application responsible for transmitting the IP packet that prompted the ICMP message to be sent.

ICMP is a network-layer protocol; this makes it a layer 3 protocol in the seven-layer OSI model. Based on the four-layer TCP/IP model, ICMP is an internet-layer protocol, which makes it a layer 2 protocol in the Internet Standard RFC 1122 TCP/IP four-layer model or a layer 3 protocol in the modern five-layer TCP/IP protocol definitions (by Kozierok, Comer, Tanenbaum, Forouzan, Kurose, Stallings).[ citation needed ]

There is no TCP or UDP port number associated with ICMP packets as these numbers are associated with the transport layer above. [3]

Datagram structure

The ICMP packet is encapsulated in an IPv4 packet. [2] The packet consists of header and data sections.

The ICMP header starts after the IPv4 header and is identified by its protocol number, 1. [4] All ICMP packets have an eight-byte header and variable-sized data section. The first four bytes of the header have fixed format, while the last four bytes depend on the type and code of the ICMP packet. [2]

ICMP header format
Offsets Octet 0123
Octet Bit 012345678910111213141516171819202122232425262728293031
00 Type Code Checksum
432 Rest of header
Type
ICMP type, see § Control messages.
Code
ICMP subtype, see § Control messages.
Checksum
Internet checksum (RFC 1071) for error checking, calculated from the ICMP header and data with value 0 substituted for this field.
Rest of header
Four-byte field, contents vary based on the ICMP type and code.

Data

ICMP error messages contain a data section that includes a copy of the entire IPv4 header, plus at least the first eight bytes of data from the IPv4 packet that caused the error message. The length of ICMP error messages should not exceed 576 bytes. [5] This data is used by the host to match the message to the appropriate process. If a higher level protocol uses port numbers, they are assumed to be in the first eight bytes of the original datagram's data. [6]

The variable size of the ICMP packet data section has been exploited. In the "Ping of death", large or fragmented ICMP packets are used for denial-of-service attacks. ICMP data can also be used to create covert channels for communication. These channels are known as ICMP tunnels.

Control messages

Control messages are identified by the value in the type field. The code field gives additional context information for the message. Some control messages have been deprecated since the protocol was first introduced.

Notable control messages [7] [8]
TypeCodeStatusDescription
0 – Echo Reply [6] :140Echo reply (used to ping)
1 and 2unassignedReserved
3 – Destination Unreachable [6] :4 [9] 0Destination network unreachable
1Destination host unreachable
2Destination protocol unreachable
3Destination port unreachable
4Fragmentation required, and DF flag set
5Source route failed
6Destination network unknown
7Destination host unknown
8Source host isolated
9Network administratively prohibited
10Host administratively prohibited
11Network unreachable for ToS
12Host unreachable for ToS
13Communication administratively prohibited
14Host Precedence Violation
15Precedence cutoff in effect
4 – Source Quench0deprecatedSource quench (congestion control)
5 – Redirect Message0Redirect Datagram for the Network
1Redirect Datagram for the Host
2Redirect Datagram for the ToS & network
3Redirect Datagram for the ToS & host
6deprecatedAlternate Host Address
7unassignedReserved
8 – Echo Request0Echo request (used to ping)
9 – Router Advertisement 0Router Advertisement
10 – Router Solicitation 0Router discovery/selection/solicitation
11 – Time Exceeded [6] :60TTL expired in transit
1Fragment reassembly time exceeded
12 – Parameter Problem: Bad IP header0Pointer indicates the error
1Missing a required option
2Bad length
13 – Timestamp0Timestamp
14 – Timestamp Reply0Timestamp reply
15 – Information Request0deprecatedInformation Request
16 – Information Reply0deprecatedInformation Reply
17 – Address Mask Request0deprecatedAddress Mask Request
18 – Address Mask Reply0deprecatedAddress Mask Reply
19reservedReserved for security
20 through 29reservedReserved for robustness experiment
30 – Traceroute 0deprecatedInformation Request
31deprecatedDatagram Conversion Error
32deprecatedMobile Host Redirect
33deprecatedWhere-Are-You (originally meant for IPv6)
34deprecatedHere-I-Am (originally meant for IPv6)
35deprecatedMobile Registration Request
36deprecatedMobile Registration Reply
37deprecatedDomain Name Request
38deprecatedDomain Name Reply
39deprecatedSKIP Algorithm Discovery Protocol, Simple Key-Management for Internet Protocol
40 Photuris, Security failures
41ExperimentalICMP for experimental mobility protocols such as Seamoby [RFC4065]
42 – Extended Echo Request [10] 0Request Extended Echo (XPing - see Extended Ping (Xping))
43 – Extended Echo Reply [10] 0No Error
1Malformed Query
2No Such Interface
3No Such Table Entry
4Multiple Interfaces Satisfy Query
44 through 252unassignedReserved
253ExperimentalRFC3692-style Experiment 1 (RFC 4727)
254ExperimentalRFC3692-style Experiment 2 (RFC 4727)
255reservedReserved

Source quench

Source Quench requests that the sender decrease the rate of messages sent to a router or host. This message may be generated if a router or host does not have sufficient buffer space to process the request, or may occur if the router or host buffer is approaching its limit.

Data is sent at a very high speed from a host or from several hosts at the same time to a particular router on a network. Although a router has buffering capabilities, the buffering is limited to within a specified range. The router cannot queue any more data than the capacity of the limited buffering space. Thus if the queue gets filled up, incoming data is discarded until the queue is no longer full. But as no acknowledgement mechanism is present in the network layer, the client does not know whether the data has reached the destination successfully. Hence some remedial measures should be taken by the network layer to avoid these kind of situations. These measures are referred to as source quench.

In a source quench mechanism, the router sees that the incoming data rate is much faster than the outgoing data rate, and sends an ICMP message to the clients, informing them that they should slow down their data transfer speeds or wait for a certain amount of time before attempting to send more data. When a client receives this message, it automatically slows down the outgoing data rate or waits for a sufficient amount of time, which enables the router to empty the queue. Thus the source quench ICMP message acts as flow control in the network layer.

Since research suggested that "ICMP Source Quench [was] an ineffective (and unfair) antidote for congestion", [11] routers' creation of source quench messages was deprecated in 1995 by RFC 1812. Furthermore, forwarding of and any kind of reaction to (flow control actions) source quench messages was deprecated from 2012 by RFC 6633.

Source quench message [6] :9
0001020304050607080910111213141516171819202122232425262728293031
Type = 4Code = 0Checksum
unused
IP header and first 8 bytes of original datagram's data

Where:

Type must be set to 4
Code must be set to 0
IP header and additional data is used by the sender to match the reply with the associated request

Redirect

An example of how an ICMPv4 redirect message works ICMPv4 redirect message example-en.svg
An example of how an ICMPv4 redirect message works

Redirect requests data packets be sent on an alternative route. ICMP Redirect is a mechanism for routers to convey routing information to hosts. The message informs a host to update its routing information (to send packets on an alternative route). If a host tries to send data through a router (R1) and R1 sends the data on another router (R2) and a direct path from the host to R2 is available (that is, the host and R2 are on the same subnetwork), then R1 will send a redirect message to inform the host that the best route for the destination is via R2. The host should then change its route information and send packets for that destination directly to R2. The router will still send the original datagram to the intended destination. [12] However, if the datagram contains routing information, this message will not be sent even if a better route is available. RFC 1122 states that redirects should only be sent by gateways and should not be sent by Internet hosts.

Redirect message [6] :11
0001020304050607080910111213141516171819202122232425262728293031
Type = 5CodeChecksum
IP address
IP header and first 8 bytes of original datagram's data

Where:

Type must be set to 5.
Code specifies the reason for the redirection, and may be one of the following:
CodeDescription
0Redirect for Network
1Redirect for Host
2Redirect for Type of Service and Network
3Redirect for Type of Service and Host
IP address is the 32-bit address of the gateway to which the redirection should be sent.
IP header and additional data is included to allow the host to match the reply with the request that caused the redirection reply.

Time exceeded

Time Exceeded is generated by a gateway to inform the source of a discarded datagram due to the time to live field reaching zero. A time exceeded message may also be sent by a host if it fails to reassemble a fragmented datagram within its time limit.

Time exceeded messages are used by the traceroute utility to identify gateways on the path between two hosts.

Time exceeded message [6] :5
0001020304050607080910111213141516171819202122232425262728293031
Type = 11CodeChecksum
unused
IP header and first 8 bytes of original datagram's data

Where:

Type must be set to 11
Code specifies the reason for the time exceeded message, include the following:
CodeDescription
0Time-to-live exceeded in transit.
1Fragment reassembly time exceeded.
IP header and first 64 bits of the original payload are used by the source host to match the time exceeded message to the discarded datagram. For higher-level protocols such as UDP and TCP the 64-bit payload will include the source and destination ports of the discarded packet.

Timestamp

Timestamp is used for time synchronization. The originating timestamp is set to the time (in milliseconds since midnight) the sender last touched the packet. The receive and transmit timestamps are not used.

Timestamp message [6] :15
0001020304050607080910111213141516171819202122232425262728293031
Type = 13Code = 0Checksum
IdentifierSequence number
Originate timestamp
Receive timestamp
Transmit timestamp

Where:

Type must be set to 13
Code must be set to 0
Identifier and Sequence Number can be used by the client to match the timestamp reply with the timestamp request.
Originate timestamp is the number of milliseconds since midnight Universal Time (UT). If a UT reference is not available the most-significant bit can be set to indicate a non-standard time value.

Timestamp reply

Timestamp Reply replies to a Timestamp message. It consists of the originating timestamp sent by the sender of the Timestamp as well as a receive timestamp indicating when the Timestamp was received and a transmit timestamp indicating when the Timestamp reply was sent.

Timestamp reply message [6] :15
0001020304050607080910111213141516171819202122232425262728293031
Type = 14Code = 0Checksum
IdentifierSequence number
Originate timestamp
Receive timestamp
Transmit timestamp

Where:

Type must be set to 14
Code must be set to 0
Identifier and Sequence number can be used by the client to match the reply with the request that caused the reply.
Originate timestamp is the time the sender last touched the message before sending it.
Receive timestamp is the time the echoer first touched it on receipt.
Transmit timestamp is the time the echoer last touched the message on sending it.
All timestamps are in units of milliseconds since midnight UT. If the time is not available in milliseconds or cannot be provided with respect to midnight UT then any time can be inserted in a timestamp provided the high order bit of the timestamp is also set to indicate this non-standard value.

The use of Timestamp and Timestamp Reply messages to synchronize the clocks of Internet nodes has largely been replaced by the UDP-based Network Time Protocol and the Precision Time Protocol. [13]

Address mask request

Address mask request is normally sent by a host to a router in order to obtain an appropriate subnet mask.

Recipients should reply to this message with an Address mask reply message.

Address mask request
0001020304050607080910111213141516171819202122232425262728293031
Type = 17Code = 0Checksum
IdentifierSequence number
Address mask

Where:

Type must be set to 17
Code must be set to 0
Address mask can be set to 0

ICMP Address Mask Request may be used as a part of reconnaissance attack to gather information on the target network, therefore ICMP Address Mask Reply is disabled by default on Cisco IOS. [14]

Address mask reply

Address mask reply is used to reply to an address mask request message with an appropriate subnet mask.

Address mask reply
0001020304050607080910111213141516171819202122232425262728293031
Type = 18Code = 0Checksum
IdentifierSequence number
Address mask

Where:

Type must be set to 18
Code must be set to 0
Address mask should be set to the subnet mask

Destination unreachable

Destination unreachable is generated by the host or its inbound gateway [6] to inform the client that the destination is unreachable for some reason. Reasons for this message may include: the physical connection to the host does not exist (distance is infinite); the indicated protocol or port is not active; the data must be fragmented but the 'don't fragment' flag is on. Unreachable TCP ports notably respond with TCP RST rather than a destination unreachable type 3 as might be expected. Destination unreachable is never reported for IP multicast transmissions.

Destination unreachable message [6] :3
0001020304050607080910111213141516171819202122232425262728293031
Type = 3CodeChecksum
unusedNext-hop MTU
IP header and first 8 bytes of original datagram's data

Where:

Type field (bits 0–7) must be set to 3
Code field (bits 8–15) is used to specify the type of error, and can be any of the following:
CodeDescription
0Network unreachable error.
1Host unreachable error.
2Protocol unreachable error (the designated transport protocol is not supported).
3Port unreachable error (the designated protocol is unable to inform the host of the incoming message).
4The datagram is too big. Packet fragmentation is required but the 'don't fragment' (DF) flag is on.
5Source route failed error.
6Destination network unknown error.
7Destination host unknown error.
8Source host isolated error.
9The destination network is administratively prohibited.
10The destination host is administratively prohibited.
11The network is unreachable for Type Of Service.
12The host is unreachable for Type Of Service.
13Communication administratively prohibited (administrative filtering prevents packet from being forwarded).
14Host precedence violation (indicates the requested precedence is not permitted for the combination of host or network and port).
15Precedence cutoff in effect (precedence of datagram is below the level set by the network administrators).
Next-hop MTU field (bits 48–63) contains the MTU of the next-hop network if a code 4 error occurs. [15]
IP header and additional data is included to allow the client to match the reply with the request that caused the destination unreachable reply.

See also

Related Research Articles

<span class="mw-page-title-main">Internet Protocol version 4</span> Fourth version of the Internet Protocol

Internet Protocol version 4 (IPv4) is the fourth version of the Internet Protocol (IP). It is one of the core protocols of standards-based internetworking methods in the Internet and other packet-switched networks. IPv4 was the first version deployed for production on SATNET in 1982 and on the ARPANET in January 1983. It is still used to route most Internet traffic today, even with the ongoing deployment of Internet Protocol version 6 (IPv6), its successor.

The Internet Protocol (IP) is the network layer communications protocol in the Internet protocol suite for relaying datagrams across network boundaries. Its routing function enables internetworking, and essentially establishes the Internet.

The Internet protocol suite, commonly known as TCP/IP, is a framework for organizing the set of communication protocols used in the Internet and similar computer networks according to functional criteria. The foundational protocols in the suite are the Transmission Control Protocol (TCP), the User Datagram Protocol (UDP), and the Internet Protocol (IP). Early versions of this networking model were known as the Department of Defense (DoD) model because the research and development were funded by the United States Department of Defense through DARPA.

In computer networking, the maximum transmission unit (MTU) is the size of the largest protocol data unit (PDU) that can be communicated in a single network layer transaction. The MTU relates to, but is not identical to the maximum frame size that can be transported on the data link layer, e.g., Ethernet frame.

ping (networking utility) Network utility used to test the reachability of a host

ping is a computer network administration software utility used to test the reachability of a host on an Internet Protocol (IP) network. It is available for virtually all operating systems that have networking capability, including most embedded network administration software.

The Transmission Control Protocol (TCP) is one of the main protocols of the Internet protocol suite. It originated in the initial network implementation in which it complemented the Internet Protocol (IP). Therefore, the entire suite is commonly referred to as TCP/IP. TCP provides reliable, ordered, and error-checked delivery of a stream of octets (bytes) between applications running on hosts communicating via an IP network. Major internet applications such as the World Wide Web, email, remote administration, and file transfer rely on TCP, which is part of the Transport layer of the TCP/IP suite. SSL/TLS often runs on top of TCP.

In computing, traceroute and tracert are computer network diagnostic commands for displaying possible routes (paths) and measuring transit delays of packets across an Internet Protocol (IP) network. The history of the route is recorded as the round-trip times of the packets received from each successive host in the route (path); the sum of the mean times in each hop is a measure of the total time spent to establish the connection. Traceroute proceeds unless all sent packets are lost more than twice; then the connection is lost and the route cannot be evaluated. Ping, on the other hand, only computes the final round-trip times from the destination point.

Time to live (TTL) or hop limit is a mechanism which limits the lifespan or lifetime of data in a computer or network. TTL may be implemented as a counter or timestamp attached to or embedded in the data. Once the prescribed event count or timespan has elapsed, data is discarded or revalidated. In computer networking, TTL prevents a data packet from circulating indefinitely. In computing applications, TTL is commonly used to improve the performance and manage the caching of data.

In computer networking, the User Datagram Protocol (UDP) is one of the core communication protocols of the Internet protocol suite used to send messages to other hosts on an Internet Protocol (IP) network. Within an IP network, UDP does not require prior communication to set up communication channels or data paths.

A datagram is a basic transfer unit associated with a packet-switched network. Datagrams are typically structured in header and payload sections. Datagrams provide a connectionless communication service across a packet-switched network. The delivery, arrival time, and order of arrival of datagrams need not be guaranteed by the network.

<span class="mw-page-title-main">Network address translation</span> Protocol facilitating connection of one IP address space to another

Network address translation (NAT) is a method of mapping an IP address space into another by modifying network address information in the IP header of packets while they are in transit across a traffic routing device. The technique was originally used to bypass the need to assign a new address to every host when a network was moved, or when the upstream Internet service provider was replaced, but could not route the network's address space. It has become a popular and essential tool in conserving global address space in the face of IPv4 address exhaustion. One Internet-routable IP address of a NAT gateway can be used for an entire private network.

In the seven-layer OSI model of computer networking, the network layer is layer 3. The network layer is responsible for packet forwarding including routing through intermediate routers.

Mobile IP is an Internet Engineering Task Force (IETF) standard communications protocol that is designed to allow mobile device users to move from one network to another while maintaining a permanent IP address. Mobile IP for IPv4 is described in IETF RFC 5944, and extensions are defined in IETF RFC 4721. Mobile IPv6, the IP mobility implementation for the next generation of the Internet Protocol, IPv6, is described in RFC 6275.

A network socket is a software structure within a network node of a computer network that serves as an endpoint for sending and receiving data across the network. The structure and properties of a socket are defined by an application programming interface (API) for the networking architecture. Sockets are created only during the lifetime of a process of an application running in the node.

In networking, a black hole refers to a place in the network where incoming or outgoing traffic is silently discarded, without informing the source that the data did not reach its intended recipient.

Internet Control Message Protocol version 6 (ICMPv6) is the implementation of the Internet Control Message Protocol (ICMP) for Internet Protocol version 6 (IPv6). ICMPv6 is an integral part of IPv6 and performs error reporting and diagnostic functions.

Path MTU Discovery (PMTUD) is a standardized technique in computer networking for determining the maximum transmission unit (MTU) size on the network path between two Internet Protocol (IP) hosts, usually with the goal of avoiding IP fragmentation. PMTUD was originally intended for routers in Internet Protocol Version 4 (IPv4). However, all modern operating systems use it on endpoints. In IPv6, this function has been explicitly delegated to the end points of a communications session. As an extension to the standard path MTU discovery, a technique called Packetization Layer Path MTU Discovery works without support from ICMP.

The internet layer is a group of internetworking methods, protocols, and specifications in the Internet protocol suite that are used to transport network packets from the originating host across network boundaries; if necessary, to the destination host specified by an IP address. The internet layer derives its name from its function facilitating internetworking, which is the concept of connecting multiple networks with each other through gateways.

An IPv6 packet is the smallest message entity exchanged using Internet Protocol version 6 (IPv6). Packets consist of control information for addressing and routing and a payload of user data. The control information in IPv6 packets is subdivided into a mandatory fixed header and optional extension headers. The payload of an IPv6 packet is typically a datagram or segment of the higher-level transport layer protocol, but may be data for an internet layer or link layer instead.

<span class="mw-page-title-main">ICMP hole punching</span> NAT technique in computer networking

ICMP hole punching is a technique employed in network address translator (NAT) applications for maintaining Internet Control Message Protocol (ICMP) packet streams that traverse the NAT. NAT traversal techniques are typically required for client-to-client networking applications on the Internet involving hosts connected in private networks, especially in peer-to-peer and Voice over Internet Protocol (VoIP) deployments.

References

  1. F. Baker (June 1995). Baker, F (ed.). Requirements for IP Version 4 Routers. p. 52. RFC   1812 .
  2. 1 2 3 4 Forouzan, Behrouz A. (2007). Data Communications And Networking (Fourth ed.). Boston: McGraw-Hill. pp.  621–630. ISBN   978-0-07-296775-3.
  3. "The OSI Model's Seven Layers Defined and Functions Explained". Microsoft Support. Retrieved 2014-12-28.
  4. "Protocol Numbers". Internet Assigned Numbers Authority. Retrieved 2011-06-23.
  5. Requirements for IP Version 4 Routers. doi: 10.17487/RFC1812 . RFC 1812.
  6. 1 2 3 4 5 6 7 8 9 10 11 Postel, J. (September 1981). Internet Control Message Protocol. IETF. doi: 10.17487/RFC0792 . RFC 792.
  7. "IANA ICMP Parameters". Iana.org. 2012-09-21. Retrieved 2013-01-07.
  8. Kurose, J.F; Ross, K.W. (2006). Computer Networking: A Top-Down Approach. World student series. Addison-Wesley. ISBN   9780321418494.
  9. "Internet Control Message Protocol (ICMP) Parameters". www.iana.org. Retrieved 2023-09-13.
  10. 1 2 PROBE: A Utility for Probing Interfaces. doi: 10.17487/RFC8335 . RFC 8335.
  11. RFC   6633
  12. "When Are ICMP Redirects Sent?". Cisco Systems. 2008-06-28. Retrieved 2013-08-15.
  13. D.L. Mills (September 1985). Network Time Protocol (NTP). doi: 10.17487/RFC0958 . RFC 958. It is evolved from the Time Protocol and the ICMP Timestamp message and is a suitable replacement for both.
  14. "Cisco IOS IP Command Reference, Volume 1 of 4: Addressing and Services, Release 12.3 - IP Addressing and Services Commands: ip mask-reply through ip web-cache". Cisco Systems. Archived from the original on 2013-01-02. Retrieved 2013-01-07.
  15. Extended ICMP to Support Multi-Part Messages. doi: 10.17487/RFC4884 . RFC 4884.

Sources

RFCs