ICMP(4)
π¦ ICMP π¦
okay bestie so this is the icmp page from the Kernel Interfaces Manual β yes the whole thing, no skips, we're doing this π
β¨ NAME β¨
icmp β Internet Control Message Protocol
πΈ SYNOPSIS πΈ
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
int
socket(AF_INET, SOCK_RAW, proto);
π DESCRIPTION π
so ICMP is the error and control message protocol that IP and the whole Internet protocol family use. you can get at it through a βraw socketβ if you're doing network monitoring or diagnostic stuff β very main character of it honestly. the proto parameter you hand to the socket call when you're making an ICMP socket comes from getprotobyname(3). π«Ά
ICMP sockets are connectionless, and normally you're vibing with the sendto(2) and recvfrom(2) calls. that said, you can also use connect(2) to lock in the destination for future packets β and if you do that, then read(2) or recv(2) and write(2) or send(2) are the moves. β¨
Outgoing packets automatically get an IP header prepended to them (based on the destination address). Incoming packets show up with the IP header and options intact. no cap.
π₯ Types π₯
ICMP messages get sorted by the type and code fields sitting in the ICMP header. and psst β the abbreviations for the types and codes can be used in rules in pf.conf(5). π
These are the types that are defined:
0Β·echorepβ Echo reply3Β·unreachβ Destination unreachable4Β·squenchβ Packet loss, slow down5Β·redirβ Shorter route exists6Β·althostβ Alternate host address8Β·echoreqβ Echo request9Β·routeradvβ Router advertisement10Β·routersolβ Router solicitation11Β·timexβ Time exceeded12Β·paramprobβ Invalid IP header13Β·timereqβ Timestamp request14Β·timerepβ Timestamp reply15Β·inforeqβ Information request16Β·inforepβ Information reply17Β·maskreqβ Address mask request18Β·maskrepβ Address mask reply30Β·traceβ Traceroute31Β·dataconvβ Data conversion problem32Β·mobredirβ Mobile host redirection33Β·ipv6-whereβ IPv6 where-are-you34Β·ipv6-hereβ IPv6 i-am-here35Β·mobregreqβ Mobile registration request36Β·mobregrepβ Mobile registration reply39Β·skipβ SKIP40Β·photurisβ Photuris
and these are the codes that are defined π (watch out, the numbers repeat across different types, that's just how it is, it's giving overlap):
0Β·net-unrβ typeunreachβ Network unreachable1Β·host-unrβ typeunreachβ Host unreachable2Β·proto-unrβ typeunreachβ Protocol unreachable3Β·port-unrβ typeunreachβ Port unreachable4Β·needfragβ typeunreachβ Fragmentation needed but DF bit set5Β·srcfailβ typeunreachβ Source routing failed6Β·net-unkβ typeunreachβ Network unknown7Β·host-unkβ typeunreachβ Host unknown8Β·isolateβ typeunreachβ Host isolated9Β·net-prohibβ typeunreachβ Network administratively prohibited10Β·host-prohibβ typeunreachβ Host administratively prohibited11Β·net-tosβ typeunreachβ Invalid TOS for network12Β·host-tosβ typeunreachβ Invalid TOS for host13Β·filter-prohibβ typeunreachβ Prohibited access14Β·host-precedβ typeunreachβ Precedence violation15Β·cutoff-precedβ typeunreachβ Precedence cutoff0Β·redir-netβ typeredirβ Shorter route for network1Β·redir-hostβ typeredirβ Shorter route for host2Β·redir-tos-netβ typeredirβ Shorter route for TOS and network3Β·redir-tos-hostβ typeredirβ Shorter route for TOS and host0Β·normal-advβ typerouteradvβ Normal advertisement16Β·common-advβ typerouteradvβ Selective advertisement0Β·transitβ typetimexβ Time exceeded in transit1Β·reassembβ typetimexβ Time exceeded in reassembly0Β·badheadβ typeparamprobβ Invalid option pointer1Β·optmissβ typeparamprobβ Missing option2Β·badlenβ typeparamprobβ Invalid length1Β·unknown-indβ typephoturisβ Unknown security index2Β·auth-failβ typephoturisβ Authentication failed3Β·decrypt-failβ typephoturisβ Decryption failed
π§ MIB Variables π§
the ICMP protocol implements a bunch of variables in the net.inet.icmp branch of the sysctl(3) MIB. here's the whole lineup, don't skip, every single one matters:
maskreplβ (boolean) Enable/disable replies to ICMP Address Mask Request packets. Defaults tofalse.maskfakeβ (unsigned integer) Whenmaskreplis set and this value is non-zero, it will be used instead of the real address mask when the system replies to an ICMP Address Mask Request packet. Defaults to0.icmplimβ (integer) Bandwidth limit for ICMP replies in packets/second. If set to zero, no limiting will occur. Defaults to200.icmplim_outputβ (boolean) Enable/disable logging of ICMP replies bandwidth limiting. Defaults totrue.drop_redirectβ (boolean) Enable/disable dropping of ICMP Redirect packets. Defaults tofalse.log_redirectβ (boolean) Enable/disable logging of ICMP Redirect packets. Defaults tofalse.bmcastechoβ (boolean) Enable/disable ICMP replies received via broadcast or multicast. Defaults tofalse.reply_srcβ (str) An interface name used for the ICMP reply source in response to packets which are not directly addressed to us. By default continue with normal source selection.reply_from_interfaceβ (boolean) Use the IP address of the interface the packet came through in for responses to packets which are not directly addressed to us. If enabled, this rule is processed before all others. By default, continue with normal source selection. Enabling this option is particularly useful on routers because it makes external traceroutes show the actual path a packet has taken instead of the possibly different return path.quotelenβ (integer) Number of bytes from original packet to quote in ICMP reply. This number is internally enforced to be at least8bytes (per RFC792) and at most the maximal space left in the ICMP reply mbuf.tstampreplβ (boolean) Enable/disable replies to ICMP Timestamp packets. Defaults totrue.
π ERRORS π
a socket operation may fail and throw one of these back at you, and honestly same:
[EISCONN]β when trying to establish a connection on a socket which already has one, or when trying to send a datagram with the destination address specified and the socket is already connected;[ENOTCONN]β when trying to send a datagram, but no destination address is specified, and the socket has not been connected;[ENOBUFS]β when the system runs out of memory for an internal data structure;[EADDRNOTAVAIL]β when an attempt is made to create a socket with a network address for which no network interface exists.
π SEE ALSO π
recv(2), send(2), inet(4), intro(4), ip(4), pf.conf(5)
β HISTORY β
The icmp protocol appeared in 4.3BSD. a legend, truly, an icon, a moment in history π
π okay that's the whole page bestie, you ate that. go ping something and think of me. π
and that's a wrap, mwah π β this was the Debian flavoured version, dated March 26, 2015. iykyk π¦
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 1986, 1991, 1993 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms