ICMP Echo-Reply (Ping)
功能概述
Ping 是一个实用的网络工具,用于测试远程主机在 IP 网络上是否可达。 它测量从源主机发送到目标目标并返回到源主机的消息的往返时间。
Ping 的工作原理是向目标主机发送 ICMP (Internet Control Message Protocol) 请求报文,并等待 ICMP 应答。
这个示例基于 cli 组件 实现了一个简单的 ping 命令。
注意: 当前此示例仅支持 IPv4。
环境要求
需要有一个能正常连接的 AP。
一个支持 shell 的串口工具。
编译和烧录
示例位置:examples/network/icmp_echo
编译、烧录等操作请参考:快速入门
运行结果
成功运行将输出如下日志
===================================================
| Steps to test icmp echo |
| |
| 1. Print 'help' to gain overview of commands |
| 2. Configure device to station or softap |
| 3. Setup WiFi connection |
| 4. Run ping to test icmp echo |
| |
===================================================
W800S2:
W800S2: ping
Usage
ping [options] <destination>
Options:
<destination> dns name or ip address
-c <count> stop after <count> replies
-i <interval> milliseconds between sending each packet
-s <size> use <size> as number of data bytes to be sent
-t <ttl> define time to live
-q <tos> define type of service
-w <timeout> milliseconds to wait for response
-h print help and exit
W800S2:
W800S2: ping www.baidu.com -c 5
32 bytes from 183.2.172.42 icmp_seq=0 ttl=52 time=42 ms
32 bytes from 183.2.172.42 icmp_seq=1 ttl=52 time=44 ms
32 bytes from 183.2.172.42 icmp_seq=2 ttl=52 time=38 ms
32 bytes from 183.2.172.42 icmp_seq=3 ttl=52 time=40 ms
32 bytes from 183.2.172.42 icmp_seq=4 ttl=52 time=38 ms
--- 183.2.172.42 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 202ms
W800S2: