下载ping程序源代码等信息,可以在这里下载

[root@ht8 network-scripts]# ping -V
ping utility, iputils-s20160308 //ping实用程序,是在iputils这个包里面
//注意iputils是个工具包,包括了arping,ping,tracepath,traceroute等一系列工具
下载地址: http://www.skbuff.net/iputils/ //当前版本 iputils-s20160308
查看 https://sourceforge.net/p/iputils/code/ci/HEAD/tree/
在线查看头
http://lxr.linux.no/linux+v5.14/include/uapi/linux/icmp.h#L89
http://lxr.linux.no/linux+v5.14/include/net/ip.h

http://lxr.linux.no/linux+v5.14/include/uapi/linux/icmp.h#L89

   1/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2/*
3 * INET An implementation of the TCP/IP protocol suite for the LINUX
4 * operating system. INET is implemented using the BSD Socket
5 * interface as the means of communication with the user level.
6 *
7 * Definitions for the ICMP protocol.
8 *
9 * Version: @(#)icmp.h 1.0.3 04/28/93
10 *
11 * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version
16 * 2 of the License, or (at your option) any later version.
17 */
18#ifndef _UAPI_LINUX_ICMP_H
19#define _UAPI_LINUX_ICMP_H
20
21#include <linux/types.h>
22#include <asm/byteorder.h>
23#include <linux/if.h>
24#include <linux/in6.h>
25
26#define ICMP_ECHOREPLY 0 /* Echo Reply */
27#define ICMP_DEST_UNREACH 3 /* Destination Unreachable */
28#define ICMP_SOURCE_QUENCH 4 /* Source Quench */
29#define ICMP_REDIRECT 5 /* Redirect (change route) */
30#define ICMP_ECHO 8 /* Echo Request */
31#define ICMP_TIME_EXCEEDED 11 /* Time Exceeded */
32#define ICMP_PARAMETERPROB 12 /* Parameter Problem */
33#define ICMP_TIMESTAMP 13 /* Timestamp Request */
34#define ICMP_TIMESTAMPREPLY 14 /* Timestamp Reply */
35#define ICMP_INFO_REQUEST 15 /* Information Request */
36#define ICMP_INFO_REPLY 16 /* Information Reply */
37#define ICMP_ADDRESS 17 /* Address Mask Request */
38#define ICMP_ADDRESSREPLY 18 /* Address Mask Reply */
39#define NR_ICMP_TYPES 18
40
41
42/* Codes for UNREACH. 这里就是code */
43#define ICMP_NET_UNREACH 0 /* Network Unreachable */
44#define ICMP_HOST_UNREACH 1 /* Host Unreachable */
45#define ICMP_PROT_UNREACH 2 /* Protocol Unreachable */
46#define ICMP_PORT_UNREACH 3 /* Port Unreachable */
47#define ICMP_FRAG_NEEDED 4 /* Fragmentation Needed/DF set */
48#define ICMP_SR_FAILED 5 /* Source Route failed */
49#define ICMP_NET_UNKNOWN 6
50#define ICMP_HOST_UNKNOWN 7
51#define ICMP_HOST_ISOLATED 8
52#define ICMP_NET_ANO 9
53#define ICMP_HOST_ANO 10
54#define ICMP_NET_UNR_TOS 11
55#define ICMP_HOST_UNR_TOS 12
56#define ICMP_PKT_FILTERED 13 /* Packet filtered */
57#define ICMP_PREC_VIOLATION 14 /* Precedence violation */
58#define ICMP_PREC_CUTOFF 15 /* Precedence cut off */
59#define NR_ICMP_UNREACH 15 /* instead of hardcoding immediate value */
60
61/* Codes for REDIRECT. */
62#define ICMP_REDIR_NET 0 /* Redirect Net */
63#define ICMP_REDIR_HOST 1 /* Redirect Host */
64#define ICMP_REDIR_NETTOS 2 /* Redirect Net for TOS */
65#define ICMP_REDIR_HOSTTOS 3 /* Redirect Host for TOS */
66
67/* Codes for TIME_EXCEEDED. */
68#define ICMP_EXC_TTL 0 /* TTL count exceeded */
69#define ICMP_EXC_FRAGTIME 1 /* Fragment Reass time exceeded */
70
71/* Codes for EXT_ECHO (PROBE) */
72#define ICMP_EXT_ECHO 42
73#define ICMP_EXT_ECHOREPLY 43
74#define ICMP_EXT_CODE_MAL_QUERY 1 /* Malformed Query */
75#define ICMP_EXT_CODE_NO_IF 2 /* No such Interface */
76#define ICMP_EXT_CODE_NO_TABLE_ENT 3 /* No such Table Entry */
77#define ICMP_EXT_CODE_MULT_IFS 4 /* Multiple Interfaces Satisfy Query */
78
79/* Constants for EXT_ECHO (PROBE) */
80#define ICMP_EXT_ECHOREPLY_ACTIVE (1 << 2)/* active bit in reply message */
81#define ICMP_EXT_ECHOREPLY_IPV4 (1 << 1)/* ipv4 bit in reply message */
82#define ICMP_EXT_ECHOREPLY_IPV6 1 /* ipv6 bit in reply message */
83#define ICMP_EXT_ECHO_CTYPE_NAME 1
84#define ICMP_EXT_ECHO_CTYPE_INDEX 2
85#define ICMP_EXT_ECHO_CTYPE_ADDR 3
86#define ICMP_AFI_IP 1 /* Address Family Identifier for ipv4 */
87#define ICMP_AFI_IP6 2 /* Address Family Identifier for ipv6 */
88
89struct icmphdr {
90 __u8 type;
91 __u8 code;
92 __sum16 checksum;
93 union {
94 struct {
95 __be16 id;
96 __be16 sequence;
97 } echo;
98 __be32 gateway;
99 struct {
100 __be16 __unused;
101 __be16 mtu;
102 } frag;
103 __u8 reserved[4];
104 } un;
105};
106
107
108/*
109 * constants for (set|get)sockopt
110 */
111
112#define ICMP_FILTER 1
113
114struct icmp_filter {
115 __u32 data;
116};
117
118/* RFC 4884 extension struct: one per message */
119struct icmp_ext_hdr {
120#if defined(__LITTLE_ENDIAN_BITFIELD)
121 __u8 reserved1:4,
122 version:4;
123#elif defined(__BIG_ENDIAN_BITFIELD)
124 __u8 version:4,
125 reserved1:4;
126#else
127#error "Please fix <asm/byteorder.h>"
128#endif
129 __u8 reserved2;
130 __sum16 checksum;
131};
132
133/* RFC 4884 extension object header: one for each object */
134struct icmp_extobj_hdr {
135 __be16 length;
136 __u8 class_num;
137 __u8 class_type;
138};
139
140/* RFC 8335: 2.1 Header for c-type 3 payload */
141struct icmp_ext_echo_ctype3_hdr {
142 __be16 afi;
143 __u8 addrlen;
144 __u8 reserved;
145};
146
147/* RFC 8335: 2.1 Interface Identification Object */
148struct icmp_ext_echo_iio {
149 struct icmp_extobj_hdr extobj_hdr;
150 union {
151 char name[IFNAMSIZ];
152 __be32 ifindex;
153 struct {
154 struct icmp_ext_echo_ctype3_hdr ctype3_hdr;
155 union {
156 __be32 ipv4_addr;
157 struct in6_addr ipv6_addr;
158 } ip_addr;
159 } addr;
160 } ident;
161};
162#endif /* _UAPI_LINUX_ICMP_H */
163

ICMP类型对应讲解

TYPE CODE Description Query Error
0 0 Echo Reply——回显应答(Ping应答) x  
3 0 Network Unreachable——网络不可达   x
3 1 Host Unreachable——主机不可达   x
3 2 Protocol Unreachable——协议不可达   x
3 3 Port Unreachable——端口不可达   x
3 4 Fragmentation needed but no frag. bit set——需要进行分片但设置不分片比特   x
3 5 Source routing failed——源站选路失败   x
3 6 Destination network unknown——目的网络未知   x
3 7 Destination host unknown——目的主机未知   x
3 8 Source host isolated (obsolete)——源主机被隔离(作废不用)   x
3 9 Destination network administratively prohibited——目的网络被强制禁止   x
3 10 Destination host administratively prohibited——目的主机被强制禁止   x
3 11 Network unreachable for TOS——由于服务类型TOS,网络不可达   x
3 12 Host unreachable for TOS         ——由于服务类型TOS,主机不可达   x
3 13 Communication administratively prohibited by filtering——由于过滤,通信被强制禁止   x
3 14 Host precedence violation——主机越权   x
3 15 Precedence cutoff in effect——优先中止生效   x
4 0 Source quench——源端被关闭(基本流控制)    
5 0 Redirect for network——对网络重定向    
5 1 Redirect for host——对主机重定向    
5 2 Redirect for TOS and network——对服务类型和网络重定向    
5 3 Redirect for TOS and host       ——对服务类型和主机重定向    
8 0 Echo request                          ——回显请求(Ping请求) x  
9 0 Router advertisement              ——路由器通告    
10 0 Route solicitation                     ——路由器请求    
11 0 TTL equals 0 during transit       ——传输期间生存时间为0   x
11 1 TTL equals 0 during reassembly——在数据报组装期间生存时间为0   x
12 0 IP header bad (catchall error)    ——坏的IP首部(包括各种差错)   x
12 1 Required options missing           ——缺少必需的选项   x
13 0 Timestamp request (obsolete)    ——时间戳请求(作废不用) x  
14   Timestamp reply (obsolete)        ——时间戳应答(作废不用) x  
15 0 Information request (obsolete)    ——信息请求(作废不用) x  
16 0 Information reply (obsolete)       ——信息应答(作废不用) x  
17 0 Address mask request                ——地址掩码请求 x  
18 0 Address mask reply                    ——地址掩码应答

icmp协议

定义(我在之前说过osi七层模型正对应着大量的rfc协议,以太网协议对应着硬件设备的通讯)
消息控制协议
https://www.rfc-editor.org/rfc/rfc792
http://www.rfc-editor.org/rfc/rfc777.txt
中文
http://www.cnpaf.net/rfc/rfc792.txt

ip协议

IP数据报的路由和转发
RFC791
https://www.rfc-editor.org/rfc/rfc791

arp协议

ARP协议的作用是通过IP地址获取MAC地址
RFC826
https://www.rfc-editor.org/rfc/rfc826.txt

linux下的头文件位置

[root@h8 net]# cat /etc/redhat-release
  CentOS Linux release 7.9.2009 (Core)

[root@h8 include]# ls
aio.h cpio.h fcntl.h grp.h langinfo.h monetary.h nfs protocols selinux string.h ucontext.h xen
aliases.h cpufreq.h features.h gshadow.h lastlog.h mqueue.h nl_types.h pthread.h semaphore.h strings.h ulimit.h xlocale.h
alloca.h crypt.h fenv.h gssapi libgen.h mtd nss.h pty.h sepol sys unistd.h zconf.h
a.out.h ctype.h fmtmsg.h gssapi.h libintl.h net obstack.h pwd.h setjmp.h syscall.h ustat.h zlib.h
argp.h dirent.h fnmatch.h gssrpc libio.h netash openssl python2.7 sgtty.h sysexits.h utime.h
argz.h dlfcn.h fpu_control.h iconv.h limits.h netatalk paths.h rdma shadow.h syslog.h utmp.h
ar.h drm fstab.h ieee754.h link.h netax25 pcrecpparg.h re_comp.h signal.h tar.h utmpx.h
arpa elf.h fts.h ifaddrs.h linux netdb.h pcrecpp.h regex.h sound termio.h values.h
asm endian.h ftw.h inttypes.h locale.h neteconet pcre.h regexp.h spawn.h termios.h verto.h
asm-generic envz.h _G_config.h kadm5 malloc.h netinet pcreposix.h resolv.h stab.h tgmath.h verto-module.h
assert.h err.h gconv.h kdb.h math.h netipx pcre_scanner.h rpc stdc-predef.h thread_db.h video
bits errno.h getopt.h keyutils.h mcheck.h netiucv pcre_stringpiece.h rpcsvc stdint.h time.h wait.h
byteswap.h error.h glob.h krad.h memory.h netpacket poll.h sched.h stdio_ext.h ttyent.h wchar.h
com_err.h et gnu krb5 misc netrom printf.h scsi stdio.h uapi wctype.h
complex.h execinfo.h gnu-versions.h krb5.h mntent.h netrose profile.h search.h stdlib.h uchar.h wordexp.h

 [root@ht8 include]# pwd
 /usr/include

ICMP TYPE CODE 对应表的更多相关文章

  1. ICMP type code 对应表(转)

    ICMP类型 TYPE CODE Description Query Error 0 0 Echo Reply——回显应答(Ping应答) x   3 0 Network Unreachable——网 ...

  2. ICMP TYPE CODE

    TYPE CODE Description Query Error 0 0 Echo Reply——回显应答(Ping应答) x   3 0 Network Unreachable——网络不可达   ...

  3. java.io.StreamCorruptedException: invalid type code: AC错误的解决方法

    问题描述: 在向一个文件写入可序列化对象时,每次只想向文件的末尾添加一个可序列化的对象,于是使用了FileOutputStream(文件名,true)间接的构建了ObjectOutputStream流 ...

  4. Replace Type Code With Class和Replace Type Code With Subclass和Replace Type Code With State/Strategy

    周末闲来写写看书总结,今天写<重构>中的3个重要手法,分别是Replace Type Code With Class.Replace Type Code With Subclass和Rep ...

  5. ObjectInputStream java.io.StreamCorruptedException: invalid type code: AC问题解决

    感谢原文作者:攻城狮_无名 原文链接:https://blog.csdn.net/mingyang_2016/article/details/75208117 问题描述: 每次向一个文件中序列化对象时 ...

  6. input type="image" 提交表单

    提到<input type="image"  />,说起来有些惭愧.之前的工作基本每周都要制作两到三个注册用户的网页.其中就用它提交表单. 那个时候我想当然的以为这是用 ...

  7. 常用6种type的form表单的input标签分析及示例

    <input> 标签用于搜集用户信息. 根据不同的 type 属性值,输入字段拥有很多种形式.输入字段可以是文本字段.复选框.掩码后的文本控件.单选按钮.按钮等等. 在这里博主介绍6中ty ...

  8. EF5.X Code First表关联与延迟加载

    1-指定导航属性,会自动生成外键,命名规则为:“表名_主键名”2-默认情况下与导航属性的主键名称相同的字段会自动被标记为外键3-通过[ForeignKey]标记指定实体类的属性为外键,4-方式2的升级 ...

  9. type="image"提交表单

    <input type="image" style="cursor:pointer; ">

随机推荐

  1. python发送邮件之宝藏库yagmail

    之前使用email模块+smtplib模块发送邮件,虽然可以实现功能,但过程比较繁琐,今天发现一个宝藏库(yagmail),可以说是炒鸡好用啦!!! 贴上实现代码,大家细品 yagmail安装 pip ...

  2. go语言学习入门篇 2--轻量级线程的实现

    很多有过 JVM 相关语言工作经验的程序员或许都遇到过如下问题: 超出 thread 限制导致内存溢出.在作者的笔记本的 linux 上运行,这种情况一般发生在创建了 11500 个左右的 threa ...

  3. K-good number Theory + 数学问题

    这道题是我做CodeTon Round1时的D题,总的来看思路很重要,有几个比较明显的切入问题的角度,要选择到最优的那个: 先看题目: 我们可以发现,这道题的描述一目了然,就是说我们能不能找k个数的和 ...

  4. C++中的RAII介绍

    摘要 RAII技术被认为是C++中管理资源的最佳方法,进一步引申,使用RAII技术也可以实现安全.简洁的状态管理,编写出优雅的异常安全的代码. 资源管理 RAII是C++的发明者Bjarne Stro ...

  5. 基于MRS-ClickHouse构建用户画像系统方案介绍

    业务场景 用户画像是对用户信息的标签化.用户画像系统通过对收集的各维度数据,进行深度的分析和挖掘,给不同的用户打上不同的标签,从而刻画出客户的全貌.通过用户画像系统,可以对各个用户进行精准定位,从而将 ...

  6. VUE常见问题

    VUE常见问题 对于MVVM的理解 MVVM 是 Model-View-ViewModel 的缩写 Model代表数据模型,也可以在Model中定义数据修改和操作的业务逻辑 View 代表UI 组件, ...

  7. Mysql查询优化器之关于JOIN的优化

    连接查询应该是比较常用的查询方式,连接查询大致分为:内连接.外连接(左连接和右连接).自然连接 下图展示了 LEFT JOIN.RIGHT JOIN.INNER JOIN.OUTER JOIN 相关的 ...

  8. python 函数基础知识

    1.函数返回的多个值会被组织成元组被返回,也可以用多个值来接收 2.调用函数时候,传入的参数叫实际参数,简称实参,定义函数的参数叫做形式参数,简称形参-- 位置参数 def mymax(x,y): a ...

  9. MySQL_fetch_array 和 MySQL_fetch_object 的区别是什么?

    以下是 MySQL_fetch_array 和 MySQL_fetch_object 的区别: MySQL_fetch_array() – 将结果行作为关联数组或来自数据库的常规数组返回. MySQL ...

  10. elasticsearch 索引数据多了怎么办,如何调优,部署 ?

    解答:索引数据的规划,应在前期做好规划,正所谓"设计先行,编码在后", 这样才能有效的避免突如其来的数据激增导致集群处理能力不足引发的线上客户 检索或者其他业务受到影响. 如何调优 ...