|11分で読めます

Pingとは?ICMP Ping、Latency、Packet Lossの仕組みを解説

Pingはもっともよく使われるネットワーク診断ツールの1つです。hostへ到達できるか、packetが往復するのにどれくらい時間がかかるか、途中でpacket lossが起きているかを確認できます。

Pingとは?

Pingは、device、website、server、IP addressへnetwork経由で到達できるかを確認するcommand-line utilityです。

Pingはround-trip time、略してRTTを測定します。RTTは小さなpacketが自分の端末から宛先へ届き、戻ってくるまでの時間です。

PingはMike Muussによって1983年に作られ、Windows、macOS、Linux、router、server、多くのnetwork applianceで利用できます。

名前はsonarに由来します。信号を送り、echoを待ち、戻ってくるまでの時間を測るという考え方です。

Pingの仕組み - ICMPの裏側

Pingは通常、ICMP (Internet Control Message Protocol) を使います。端末はICMP Echo Requestを送り、ICMP Echo Replyが返るのを待ちます。

You run:
  ping google.com

1. DNS resolution
   google.com -> 142.250.80.46

2. ICMP Echo Request
   Source:      your IP address
   Destination: 142.250.80.46
   Type:        8
   Code:        0
   Sequence:    1
   Payload:     small test data

3. Network path
   The packet travels through routers between you and the server.

4. ICMP Echo Reply
   Source:      142.250.80.46
   Destination: your IP address
   Type:        0
   Code:        0
   Sequence:    1

5. Round-trip time
   RTT = reply received time - request sent time
   Example: 12 ms

よく使われるICMP message type

TypeName用途
Type 0Echo ReplyPing response
Type 3Destination Unreachablenetwork、host、protocol、portへ到達できないerror
Type 8Echo RequestPing request
Type 11Time Exceededtracerouteやrouting loopの診断

LatencyとRound-Trip Timeを理解する

Latencyは遅延です。ping outputでは通常、packetがtargetへ行って戻るまでの時間がmillisecondsで表示されます。

RTT品質意味
1-20 ms非常に良い同じ都市、LAN、近いdata center、高速なfiber経路
20-50 ms良い通常のWeb閲覧、video call、gameが快適
50-100 ms許容範囲利用できるがreal-time appでは少し鈍く感じることがある
100-200 ms高いcall、game、remote desktopで遅延を感じやすい
200+ ms非常に高い長距離、satellite、混雑、routing問題が原因のことが多い

Packet Lossとは?

Packet lossは、一部のpacketが戻ってこない状態です。わずかなlossでもvideo callの乱れ、gameのlag、download低速化、Webの不安定さにつながります。

Packet loss影響
0%通常利用では健全な接続
1-2%call、game、streamingでは小さいが体感できることがある
3-5%stutter、retry、不安定な接続が起きやすい
10%+すぐに調査すべき深刻な問題

Jitter - なぜ安定性が重要なのか

Jitterはlatencyのばらつきです。25 ms、26 ms、24 msで安定して返る接続は、20 msから180 msへ跳ねる接続よりずっと滑らかに感じます。

Ping Commandの使い方

ping commandは主要OSに組み込まれていますが、WindowsとUnix系OSではoptionが少し異なります。

Windows:
  ping example.com
  ping -n 10 example.com
  ping -4 example.com
  ping -6 example.com

macOS and Linux:
  ping example.com
  ping -c 10 example.com
  ping -i 0.5 example.com
  ping -s 1200 example.com

Ping結果の読み方

ping resultには、reply size、source IP、sequence number、TTL、time、packet loss、min/avg/max latencyなど、役立つ手がかりが含まれます。

PING example.com (93.184.216.34): 56 data bytes
64 bytes from 93.184.216.34: icmp_seq=0 ttl=56 time=18.4 ms
64 bytes from 93.184.216.34: icmp_seq=1 ttl=56 time=17.9 ms
64 bytes from 93.184.216.34: icmp_seq=2 ttl=56 time=19.1 ms
64 bytes from 93.184.216.34: icmp_seq=3 ttl=56 time=18.0 ms

--- example.com ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 17.9/18.4/19.1/0.5 ms
Field意味
timeそのreply単体のround-trip time
ttlTime To Live。通過したrouter数を推測する手がかりになるhop limit
icmp_seqrequestとreplyを対応付けるためのsequence number
packet loss送信したpacketのうちreplyを受け取れなかった割合
min/avg/max観測されたround-trip timeの最小、平均、最大

Ping Timeに影響するもの

Ping timeは回線速度だけで決まりません。距離、routing、Wi-Fi品質、混雑、server負荷、VPN、firewallなどが結果に影響します。

要因影響
距離遠いserverほどlatencyは高くなりやすい
Routingtrafficが複数networkを経由し、遠回りすることがある
Wi-Fi品質弱いsignalや干渉はdelayやlossを増やす
Congestion混雑したnetworkはpacketをqueueし、latencyを増やす
VPNまたはproxy別serverを経由するため追加の経路が増える
Server policy一部hostはICMP pingをrate-limitまたはblockする

良いPing値とは?

良いping値は用途によって変わります。Web閲覧は高めのlatencyにも耐えますが、game、call、remote desktopでは低く安定したlatencyが必要です。

用途目安となるping値
Web browsing100 ms未満なら通常は問題ない
Video streaminglatencyよりbandwidthと安定性が重要
Video calls50 ms未満が良い。jitterの低さも重要
Online gaming30 ms未満は非常に良い。60 ms未満なら多くの場合playable
Remote desktop50 ms未満だとかなり反応が良く感じる

Pingでネットワークを切り分ける

Pingはlayerを1つずつ確認できるため便利です。まずlocal、次にrouter、外部IP、domain nameの順に試すと原因を切り分けやすくなります。

Troubleshooting sequence:

1. Ping your own computer
   ping 127.0.0.1

2. Ping your router
   ping 192.168.1.1

3. Ping a public IP
   ping 8.8.8.8

4. Ping a domain name
   ping google.com

If 8.8.8.8 works but google.com fails,
the problem is probably DNS, not general connectivity.

Pingの先へ - 関連ツール

Pingは診断ツールの1つにすぎません。traceroute、DNS lookup、HTTP check、speed testと組み合わせると、問題の全体像を把握しやすくなります。

Toolできること
Traceroute自分から宛先までのrouter hopを表示する
DNS lookupdomainが期待したIP addressへresolveされるか確認する
HTTP headers checkerWebサイトがHTTP layerで応答しているか確認する
Redirect checkerページを遅く感じさせるredirect chainを表示する
Speed testlatencyとは別のthroughputを測定する

PingでHostをテスト

無料のPing Checkerで、browserからreachability、response time、packet loss、network behaviorを確認できます。

Ping Checkerを開く

参考資料

  • RFC 792 - Internet Control Message Protocol
  • RFC 4443 - ICMPv6 for the Internet Protocol Version 6 Specification
  • Mike Muuss ping history and original network utility notes
  • Microsoft, Apple, and Linux ping command documentation