Linux ping 命令从哪里获取它的 id 计数器?

Linux ping 命令从哪里获取它的 id 计数器?

我注意到pingiputils)id每次执行时都会增加 ICMP 计数器。我试着看看平源代码扫了一眼却没有找到柜台。 AFAIK ping 不运行任何守护进程或其他系统全局状态,那么 Linux 内核本身是否保存此计数器的记录?

% ping -c 3 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.039 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.039 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.033 ms

Tshark(id = 0x0043):

14267 196372.989831489    127.0.0.1 → 127.0.0.1    ICMP 98 Echo (ping) request  id=0x0043, seq=1/256, ttl=64
14268 196372.989843064    127.0.0.1 → 127.0.0.1    ICMP 98 Echo (ping) reply    id=0x0043, seq=1/256, ttl=64 (request in 14267)
14269 196374.001333266    127.0.0.1 → 127.0.0.1    ICMP 98 Echo (ping) request  id=0x0043, seq=2/512, ttl=64
14270 196374.001345051    127.0.0.1 → 127.0.0.1    ICMP 98 Echo (ping) reply    id=0x0043, seq=2/512, ttl=64 (request in 14269)
14271 196375.014707417    127.0.0.1 → 127.0.0.1    ICMP 98 Echo (ping) request  id=0x0043, seq=3/768, ttl=64
14272 196375.014717838    127.0.0.1 → 127.0.0.1    ICMP 98 Echo (ping) reply    id=0x0043, seq=3/768, ttl=64 (request in 14271)

再次平:

% ping -c 3 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.047 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.062 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.037 ms

Tshark(id = 0x0044):

14273 196381.959906106    127.0.0.1 → 127.0.0.1    ICMP 98 Echo (ping) request  id=0x0044, seq=1/256, ttl=64
14274 196381.959921324    127.0.0.1 → 127.0.0.1    ICMP 98 Echo (ping) reply    id=0x0044, seq=1/256, ttl=64 (request in 14273)
14275 196382.961393309    127.0.0.1 → 127.0.0.1    ICMP 98 Echo (ping) request  id=0x0044, seq=2/512, ttl=64
14276 196382.961404803    127.0.0.1 → 127.0.0.1    ICMP 98 Echo (ping) reply    id=0x0044, seq=2/512, ttl=64 (request in 14275)
14277 196383.974709944    127.0.0.1 → 127.0.0.1    ICMP 98 Echo (ping) request  id=0x0044, seq=3/768, ttl=64
14278 196383.974722217    127.0.0.1 → 127.0.0.1    ICMP 98 Echo (ping) reply    id=0x0044, seq=3/768, ttl=64 (request in 14277)

相关内容