Linux pingコマンドはIDカウンタをどこで取得しますか?

Linux pingコマンドはIDカウンタをどこで取得しますか?

気づいたping(アイチルス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)

ベストアンサー1

おすすめ記事