| manpages.info - online man pages | ![]() |
|||
|
icmp (4) Table of Contents
Nameicmp - Internet Control Message Protocol
Synopsis
#include <sys/socket.h>
int
DescriptionICMP is the error and control message protocol used by IP and the Internet protocol family. It may be accessed through a ``raw socket'' for network monitoring and diagnostic functions. The proto parameter to the socket call to create an ICMP socket is obtained from getprotobyname(3) . ICMP sockets are connectionless, and are normally used with the sendto and recvfrom calls, though the connect(2) call may also be used to fix the destination for future packets (in which case the read(2) or recv(2) and write(2) or send(2) system calls may be used).
Outgoing packets automatically have an IP header prepended to them (based on the destination address). Incoming packets are received with the IP header and options intact.
Non-privileged ICMP
socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP)
This can be used by non root privileged processes to send ICMP echo requests to gauge the quality of the connectivity to a host, to receive ICMP destination unreachable message for path MTU discovery, or to receveive time exceeded message for traceroute.
Datagram oriented ICMP sockets offer a subset of the functionality available to raw ICMP sockets. Only IMCP request messages of the following types can be sent: ICMP_ECHO, ICMP_TSTAMP or ICMP_MASKREQ. The code field must be the value zero (0). The minimal length of an ICMP message request is eight (8) octets.
The following IP level option can be used with datagram oriented ICMP sockets:
When the IP option IP_HDRINCL is used, the provided IP header must obey the following rules:
The maximum length of a IMCP message that can be sent is controlled by the sysctl variable net.inet.raw.maxdgram.
DiagnosticsA socket operation may fail with one of the following errors returned:
[EADDRNOTAVAIL] when an attempt is made to create a socket with a network address for which no network interface exists;
See Alsosend(2) , recv(2) , intro(4) , inet(4) , ip(4)
HistoryThe icmp protocol appeared in 4.3BSD.
|