聊聊Ping命令的返回值Pong

Pong 是什么?见文末~

在写程序代码、运维时经常会使用ping测试连通性,成功时也会看到一个返回值Pong
为什么不返回success呢,如果不了解ICMP协议就不能窥探原因。
下面看看返回Pong的示例:

一、使用java中的Jedis类连接Redis测试时:

Jedis 是 Redis 官方首选的 Java 客户端开发包。
1.测试连通性
public class Demo01 {
  public static void main(String[] args) {
    //连接本地的 Redis 服务
    Jedis jedis = new Jedis("127.0.0.1",6379);
    //查看服务是否运行,打出pong表示OK
    System.out.println(jedis.ping());
  }

java中使用jedis测试连通性返回值pong
在这里插入图片描述

二、使用Ansible运维时:

检查指定节点机器是否还能连通,用法很简单,不涉及参数,主机如果在线,则回复pong

[root@localhost ~]# ansible erp -m ping
192.168.10.6 | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}
192.168.10.7 | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}

ping = protocol ICMP, type 8(request), code 0
pong = protocol ICMP, type 0(reply), code 0

Ping is a computer network application used to test whether a particular host is reachable across an IP
network. It is also used to self-test the network interface card of the computer or as a latency test. It works
by sending ICMP “echo reply” packets to the target host and listening for ICMP “echo reply” replies. The
“echo reply” is sometimes called a pong. Ping measures the round-trip time, records packet loss, and
prints a statistical summary of the echo reply packets received (the minimum, maximum, and the mean of
the round-trip times and in some versions the standard deviation of the mean).

参考连接
http://gaia.cs.umass.edu/kurose_ross/programming/Python_code/ICMPping.pdf

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值