TCP/IP协议(8): ICMP(Internet Control Message Protocol) 协议 ——诊断和控制 IP 协议层

TCP/IP协议(8): ICMP(Internet Control Message Protocol) 协议 ——诊断和控制 IP 协议层

关于网际控制报文协议(Internet Control Message Protocol, ICMP)

网际控制报文协议(Internet Control Message Protocol, ICMP) 是定义在 RFC 792 中的因特网协议套件的一部分。ICMP 报文通常用于诊断或控制目的,它也可以用于响应 IP 操作中的错误(定义于 RFC 1122)。
(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 协议介于传输层网络层之间。不能说它是网络层协议,是因为它依赖于所有的 IP 协议实现,ICMP 报文在传输过程中,又很可能被传输层解析处理。

尽管如此,我们通常仍然认为 ICMP 协议网络层协议。维基百科对此有如下解释:

ICMP 协议使用了 IP 协议的基本支持,以至于它好像是更高层的协议。然而, ICMP 协议实际上是 IP 协议的一个组成部分。尽管 ICMP 报文被封装在标准 IP 协议包中,但与一般的 IP 包处理不同,ICMP 报文通常作为特殊情况处理。
(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. )

ICMP 报文

ICMP 报文首部

  • 类型(Type): 1 字节。 定义该 ICMP 报文的类型。常用的类型值如下:

    类型值正式名称注释
    0回显应答ping 的应答
    3目的不可达不可达的主机/协议
    5重定向表示应该被使用的可选路由器
    8回显回显请求
    11超时资源耗尽
    12参数问题有问题的数据包或首部
  • 代码(Code):1 字节。ICMP 报文 子类型。进一步的解释该 ICMP 报文的作用。目标不可达类型常见代码如下:

    代码值正式名称注释
    0网路不可达(完全) 没有路由到目的地
    1主机不可达已知但不可达的主机
    2协议不可达未知的(传输)协议
    3端口不可达未知的端口
    4需要进行分片但设置不分片位需要设置分片但被 DF 禁止
  • 校验和(Checksum): 2 字节。该 ICMP 报文首部数据计算出的校验和。

  • ICMP 首部剩余部分(Rest Of Header):4 字节。根据不同的类型代码,表达不同的含义。

  • ICMP 数据ICMP 报文携带的附加数据。

常见的 ICMP 报文

ICMP 回显类型 — 分组网际探测(Packet InterNet Groper, PING)

我们通常使用 PING 操作来测试主机之间的连通性。该操作使用的 ICMP 回显报文结构如下:
ICMP 回显
其中,回显请求类型值是 8, 回显应答类型值是 0。其对应的代码值都为 0。
标识符序列号用于匹配回显应答回显请求有效负载可能包括一个表示传输时间的时间戳和一个序列号,这允许 PING 以无状态的方式计算往返时间(Round Trip Time, RTT),而不需要记录每个包的传输时间。

目标不可达报文(Destination Unreachable)

目标不可到达报文由主机或其入站网关生成,用于通知客户端由于某种原因目标网络设备不可到达。
目标不可达报文
其中,类型值为 3, 表示网络不可达。 代码值用于标识目标设备不可达的具体原因,常见代码值如前文所示。
下一跳最大传输单元代码值为 4 时有效,存放下一跳网络的 MTU
IP 首部及原始数据报数据的前 8 字节用于客户端识别目标不可到达报文所对应的原报文。

参考文献

  • 7
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
INTRODUCTION lwIP is a small independent implementation of the TCP/IP protocol suite. The focus of the lwIP TCP/IP implementation is to reduce the RAM usage while still having a full scale TCP. This making lwIP suitable for use in embedded systems with tens of kilobytes of free RAM and room for around 40 kilobytes of code ROM. lwIP was originally developed by Adam Dunkels at the Computer and Networks Architectures (CNA) lab at the Swedish Institute of Computer Science (SICS) and is now developed and maintained by a worldwide network of developers. FEATURES * IP (Internet Protocol, IPv4 and IPv6) including packet forwarding over multiple network interfaces * ICMP (Internet Control Message Protocol) for network maintenance and debugging * IGMP (Internet Group Management Protocol) for multicast traffic management * MLD (Multicast listener discovery for IPv6). Aims to be compliant with RFC 2710. No support for MLDv2 * ND (Neighbor discovery and stateless address autoconfiguration for IPv6). Aims to be compliant with RFC 4861 (Neighbor discovery) and RFC 4862 (Address autoconfiguration) * DHCP, AutoIP/APIPA (Zeroconf), ACD (Address Conflict Detection) and (stateless) DHCPv6 * UDP (User Datagram Protocol) including experimental UDP-lite extensions * TCP (Transmission Control Protocol) with congestion control, RTT estimation fast recovery/fast retransmit and sending SACKs * raw/native API for enhanced performance * Optional Berkeley-like socket API * TLS: optional layered TCP ("altcp") for nearly transparent TLS for any TCP-based protocol (ported to mbedTLS) (see changelog for more info) * PPPoS and PPPoE (Point-to-point protocol over Serial/Ethernet) * DNS (Domain name resolver incl. mDNS) * 6LoWPAN (via IEEE 802.15.4, BLE or ZEP) APPLICATIONS * HTTP server with SSI and CGI (HTTPS via altcp) * SNMPv2c agent with MIB compiler (Simple Network Management Protocol), v3 via altcp * SNTP (Simple network time protocol) * NetBIOS name service responder * MDNS (Multicast DNS) responder * iPerf server implementation * MQTT client (TLS support via altcp) LICENSE lwIP is freely available under a BSD license. DEVELOPMENT lwIP has grown into an excellent TCP/IP stack for embedded devices, and developers using the stack often submit bug fixes, improvements, and additions to the stack to further increase its usefulness. Development of lwIP is hosted on Savannah, a central point for software development, maintenance and distribution. Everyone can help improve lwIP by use of Savannah's interface, Git and the mailing list. A core team of developers will commit changes to the Git source tree. The lwIP TCP/IP stack is maintained in the 'lwip' Git module and contributions (such as platform ports) are in the 'contrib' Git module. See doc/savannah.txt for details on Git server access for users and developers. The current Git trees are web-browsable: http://git.savannah.gnu.org/cgit/lwip.git http://git.savannah.gnu.org/cgit/lwip/lwip-contrib.git Submit patches and bugs via the lwIP project page: http://savannah.nongnu.org/projects/lwip/ Continuous integration builds (GCC, clang): https://travis-ci.org/lwip-tcpip/lwip DOCUMENTATION Self documentation of the source code is regularly extracted from the current Git sources and is available from this web page: http://www.nongnu.org/lwip/ Also, there are mailing lists you can subscribe at http://savannah.nongnu.org/mail/?group=lwip plus searchable archives: http://lists.nongnu.org/archive/html/lwip-users/ http://lists.nongnu.org/archive/html/lwip-devel/ There is a wiki about lwIP at http://lwip.wikia.com/wiki/LwIP_Wiki You might get questions answered there, but unfortunately, it is not as well maintained as it should be. lwIP was originally written by Adam Dunkels: http://dunkels.com/adam/ Reading Adam's papers, the files in docs/, browsing the source code documentation and browsing the mailing list archives is a good way to become familiar with the design of lwIP. Adam Dunkels Leon Woestenberg
网络协议TCP/IP实验五是对ICMPInternet Control Message Protocol,互联网控制报文协议协议进行分析实验。ICMPTCP/IP协议族中的一个重要协议,主要用于在IP网络中传递诊断控制信息。 在实验中,首先需要了解ICMP协议的作用和功能。ICMP协议主要用于网络的故障排除和错误报告,它可以对某些错误情况作出响应并提供相应的错误报告。例如,当IP包无法到达目的地时,ICMP协议可以发送“目标不可达”错误报告;当网络拥塞或繁忙时,ICMP协议可以发送“超时”报告。此外,ICMP协议还可以用于网络探测和诊断,如发送“回显请求”报文以测试网络的可达性和延迟。 实验中可以通过使用网络抓包工具(如Wireshark)来捕获ICMP协议相关的数据包。通过分析数据包的格式和字段,可以理解ICMP协议的具体工作机制。ICMP报文中包含各种类型的消息,如目标不可达、回显请求和回显回答等,通过分析报文中的各个字段,可以了解每个消息的作用和承载的信息。 在分析ICMP协议时,还可以关注ICMP协议与其他协议的配合使用。例如,ICMP协议通常与IP协议配合使用,用于传递错误和控制信息。此外,ICMP报文也可以嵌入到其他协议的数据包中,如在Ping命令中使用ICMP报文进行网络连通性测试。 通过实验分析ICMP协议,我们可以更深入地理解网络协议的工作原理,并掌握网络故障排除和网络诊断的技巧。同时,对于网络安全和网络性能优化也有一定的帮助。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值